Changeset 7943c43 in mainline for uspace/lib/nic/src/nic_impl.c
- Timestamp:
- 2012-01-16T22:45:38Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 32817cc, 3fe58d3c
- Parents:
- 9117ef9b (diff), 3ea725e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/nic/src/nic_impl.c
r9117ef9b r7943c43 39 39 #include <ipc/services.h> 40 40 #include <ns.h> 41 #include <packet_client.h>42 #include <packet_remote.h>43 41 #include "nic_driver.h" 44 42 #include "nic_impl.h" … … 159 157 160 158 /** 161 * Default implementation of the send_ message method.159 * Default implementation of the send_frame method. 162 160 * Send messages to the network. 163 161 * 164 162 * @param fun 165 * @param packet_id ID of the first packet in a queue of sent packets 163 * @param data Frame data 164 * @param size Frame size in bytes 166 165 * 167 166 * @return EOK If the message was sent 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; 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; 175 172 176 173 fibril_rwlock_read_lock(&nic_data->main_lock); 177 174 if (nic_data->state != NIC_STATE_ACTIVE || nic_data->tx_busy) { 178 175 fibril_rwlock_read_unlock(&nic_data->main_lock); 179 pq_release_remote(nic_data->net_session, packet_id);180 176 return EBUSY; 181 177 } 182 178 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); 179 nic_data->send_frame(nic_data, data, size); 203 180 return EOK; 204 181 }
Note:
See TracChangeset
for help on using the changeset viewer.