Changeset 0b749a3 in mainline for uspace/lib/net/generic/packet_remote.c
- Timestamp:
- 2010-11-22T15:39:53Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0eddb76, aae339e9
- Parents:
- 9a1d8ab (diff), 8cd1aa5e (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/net/generic/packet_remote.c
r9a1d8ab r0b749a3 27 27 */ 28 28 29 /** @addtogroup packet30 * 29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * 35 * 34 * Packet client interface implementation for remote modules. 35 * @see packet_client.h 36 36 */ 37 37 … … 39 39 #include <errno.h> 40 40 #include <ipc/ipc.h> 41 #include <ipc/packet.h> 41 42 #include <sys/mman.h> 42 43 43 #include <net_err.h> 44 #include <net_messages.h> 45 #include <packet/packet.h> 46 #include <packet/packet_client.h> 47 #include <packet/packet_header.h> 48 #include <packet/packet_messages.h> 44 #include <packet_client.h> 49 45 #include <packet_remote.h> 46 47 #include <net/packet.h> 48 #include <net/packet_header.h> 50 49 51 50 /** Obtain the packet from the packet server as the shared memory block. … … 64 63 * 65 64 */ 66 static int packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size){67 ERROR_DECLARE; 68 65 static int 66 packet_return(int phone, packet_t **packet, packet_id_t packet_id, size_t size) 67 { 69 68 ipc_call_t answer; 70 aid_t message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer); 71 *packet = (packet_t) as_get_mappable_page(size); 72 if (ERROR_OCCURRED(async_share_in_start_0_0(phone, *packet, size)) 73 || ERROR_OCCURRED(pm_add(*packet))) { 69 aid_t message; 70 int rc; 71 72 message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer); 73 74 *packet = (packet_t *) as_get_mappable_page(size); 75 rc = async_share_in_start_0_0(phone, *packet, size); 76 if (rc != EOK) { 74 77 munmap(*packet, size); 75 78 async_wait_for(message, NULL); 76 return ERROR_CODE; 79 return rc; 80 } 81 rc = pm_add(*packet); 82 if (rc != EOK) { 83 munmap(*packet, size); 84 async_wait_for(message, NULL); 85 return rc; 77 86 } 78 87 … … 83 92 } 84 93 85 int packet_translate_remote(int phone, packet_ref packet, packet_id_t packet_id) 86 { 87 ERROR_DECLARE; 94 /** Translates the packet identifier to the packet reference. 95 * 96 * Tries to find mapping first. 97 * Contacts the packet server to share the packet if the mapping is not present. 98 * 99 * @param[in] phone The packet server module phone. 100 * @param[out] packet The packet reference. 101 * @param[in] packet_id The packet identifier. 102 * @return EOK on success. 103 * @return EINVAL if the packet parameter is NULL. 104 * @return Other error codes as defined for the NET_PACKET_GET_SIZE 105 * message. 106 * @return Other error codes as defined for the packet_return() 107 * function. 108 */ 109 int packet_translate_remote(int phone, packet_t **packet, packet_id_t packet_id) 110 { 111 int rc; 88 112 89 113 if (!packet) … … 91 115 92 116 *packet = pm_find(packet_id); 93 if (! (*packet)) {117 if (!*packet) { 94 118 ipcarg_t size; 95 119 96 ERROR_PROPAGATE(async_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id, &size)); 97 ERROR_PROPAGATE(packet_return(phone, packet, packet_id, size)); 98 } 99 if ((** packet).next) { 100 packet_t next; 120 rc = async_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id, 121 &size); 122 if (rc != EOK) 123 return rc; 124 rc = packet_return(phone, packet, packet_id, size); 125 if (rc != EOK) 126 return rc; 127 } 128 if ((*packet)->next) { 129 packet_t *next; 101 130 102 return packet_translate_remote(phone, &next, (* * packet).next);131 return packet_translate_remote(phone, &next, (*packet)->next); 103 132 } 104 133 … … 106 135 } 107 136 108 packet_t packet_get_4_remote(int phone, size_t max_content, size_t addr_len, 137 /** Obtains the packet of the given dimensions. 138 * 139 * Contacts the packet server to return the appropriate packet. 140 * 141 * @param[in] phone The packet server module phone. 142 * @param[in] addr_len The source and destination addresses maximal length in 143 * bytes. 144 * @param[in] max_prefix The maximal prefix length in bytes. 145 * @param[in] max_content The maximal content length in bytes. 146 * @param[in] max_suffix The maximal suffix length in bytes. 147 * @return The packet reference. 148 * @return NULL on error. 149 */ 150 packet_t *packet_get_4_remote(int phone, size_t max_content, size_t addr_len, 109 151 size_t max_prefix, size_t max_suffix) 110 152 { 111 ERROR_DECLARE;112 113 153 ipcarg_t packet_id; 114 154 ipcarg_t size; 115 116 if (ERROR_OCCURRED(async_req_4_2(phone, NET_PACKET_CREATE_4, max_content, 117 addr_len, max_prefix, max_suffix, &packet_id, &size))) 155 int rc; 156 157 rc = async_req_4_2(phone, NET_PACKET_CREATE_4, max_content, addr_len, 158 max_prefix, max_suffix, &packet_id, &size); 159 if (rc != EOK) 118 160 return NULL; 119 161 120 162 121 packet_t packet = pm_find(packet_id);163 packet_t *packet = pm_find(packet_id); 122 164 if (!packet) { 123 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size))) 165 rc = packet_return(phone, &packet, packet_id, size); 166 if (rc != EOK) 124 167 return NULL; 125 168 } … … 128 171 } 129 172 130 packet_t packet_get_1_remote(int phone, size_t content) 131 { 132 ERROR_DECLARE; 133 173 /** Obtains the packet of the given content size. 174 * 175 * Contacts the packet server to return the appropriate packet. 176 * 177 * @param[in] phone The packet server module phone. 178 * @param[in] content The maximal content length in bytes. 179 * @return The packet reference. 180 * @return NULL on error. 181 */ 182 packet_t *packet_get_1_remote(int phone, size_t content) 183 { 134 184 ipcarg_t packet_id; 135 185 ipcarg_t size; 136 137 if (ERROR_OCCURRED(async_req_1_2(phone, NET_PACKET_CREATE_1, content, 138 &packet_id, &size))) 186 int rc; 187 188 rc = async_req_1_2(phone, NET_PACKET_CREATE_1, content, &packet_id, 189 &size); 190 if (rc != EOK) 139 191 return NULL; 140 192 141 packet_t packet = pm_find(packet_id);193 packet_t *packet = pm_find(packet_id); 142 194 if (!packet) { 143 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size))) 195 rc = packet_return(phone, &packet, packet_id, size); 196 if (rc != EOK) 144 197 return NULL; 145 198 } … … 148 201 } 149 202 203 /** Releases the packet queue. 204 * 205 * All packets in the queue are marked as free for use. 206 * The packet queue may be one packet only. 207 * The module should not use the packets after this point until they are 208 * received or obtained again. 209 * 210 * @param[in] phone The packet server module phone. 211 * @param[in] packet_id The packet identifier. 212 */ 150 213 void pq_release_remote(int phone, packet_id_t packet_id) 151 214 {
Note:
See TracChangeset
for help on using the changeset viewer.