Changes in uspace/lib/nic/src/nic_impl.c [6d8455d:00d7e1b] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/nic/src/nic_impl.c
r6d8455d r00d7e1b 39 39 #include <ipc/services.h> 40 40 #include <ns.h> 41 #include <packet_client.h> 42 #include <packet_remote.h> 41 43 #include "nic_driver.h" 42 44 #include "nic_impl.h" … … 157 159 158 160 /** 159 * Default implementation of the send_ frame method.161 * Default implementation of the send_message method. 160 162 * Send messages to the network. 161 163 * 162 164 * @param fun 163 * @param data Frame data 164 * @param size Frame size in bytes 165 * @param packet_id ID of the first packet in a queue of sent packets 165 166 * 166 167 * @return EOK If the message was sent 167 * @return EBUSY If the device is not in state when the frame can be sent. 168 */ 169 int nic_send_frame_impl(ddf_fun_t *fun, void *data, size_t size) 170 { 171 nic_t *nic_data = (nic_t *) fun->driver_data; 168 * @return EBUSY If the device is not in state when the packet can be set. 169 * @return EINVAL If the packet ID is invalid 170 */ 171 int nic_send_message_impl(ddf_fun_t *fun, packet_id_t packet_id) 172 { 173 nic_t *nic_data = (nic_t *) fun->driver_data; 174 packet_t *packet, *next; 172 175 173 176 fibril_rwlock_read_lock(&nic_data->main_lock); 174 177 if (nic_data->state != NIC_STATE_ACTIVE || nic_data->tx_busy) { 175 178 fibril_rwlock_read_unlock(&nic_data->main_lock); 179 pq_release_remote(nic_data->net_session, packet_id); 176 180 return EBUSY; 177 181 } 178 182 179 nic_data->send_frame(nic_data, data, size); 183 int rc = packet_translate_remote(nic_data->net_session, &packet, packet_id); 184 185 if (rc != EOK) { 186 fibril_rwlock_read_unlock(&nic_data->main_lock); 187 return EINVAL; 188 } 189 190 /* 191 * Process the packet queue. Each sent packet must be detached from the 192 * queue and destroyed. This is why the cycle differs from loopback's 193 * cycle, where the packets are immediately used in upper layers and 194 * therefore they must not be destroyed (released). 195 */ 196 assert(nic_data->write_packet != NULL); 197 do { 198 next = pq_detach(packet); 199 nic_data->write_packet(nic_data, packet); 200 packet = next; 201 } while (packet); 202 fibril_rwlock_read_unlock(&nic_data->main_lock); 180 203 return EOK; 181 204 }
Note:
See TracChangeset
for help on using the changeset viewer.