| 199 | } |
| 200 | |
| 201 | FError FXmacMsgSgsend(FXmacMsgOs *instance_p, struct pbuf *p) |
| 202 | { |
| 203 | struct pbuf *q; |
| 204 | u32 n_pbufs; |
| 205 | FXmacMsgBd *txbdset, *txbd, *last_txbd = NULL; |
| 206 | FXmacMsgBd *temp_txbd; |
| 207 | FError status; |
| 208 | FXmacMsgBdRing *txring; |
| 209 | u32 bdindex; |
| 210 | uintptr tx_payload ; |
| 211 | u32 max_fr_size; |
| 212 | |
| 213 | |
| 214 | txring = &(FXMAC_MSG_GET_TXRING(instance_p->instance)); |
| 215 | |
| 216 | /* first count the number of pbufs */ |
| 217 | for (q = p, n_pbufs = 0; q != NULL; q = q->next) |
| 218 | { |
| 219 | n_pbufs++; |
| 220 | } |
| 221 | |
| 222 | /* obtain as many BD's */ |
| 223 | status = FXmacMsgBdRingAlloc(txring, n_pbufs, &txbdset); |
| 224 | if (status != FT_SUCCESS) |
| 225 | { |
| 226 | LOG_I("sgsend: Error allocating TxBD."); |
| 227 | return ERR_GENERAL; |
| 228 | } |
| 229 | |
| 230 | for (q = p, txbd = txbdset; q != NULL; q = q->next) |
| 231 | { |
| 232 | bdindex = FXMAC_MSG_BD_TO_INDEX(txring, txbd); |
| 233 | |
| 234 | if (instance_p->buffer.tx_pbufs_storage[bdindex]) |
| 235 | { |
| 236 | LOG_I("txbd %p, txring->base_bd_addr %p", txbd, txring->base_bd_addr); |
| 237 | LOG_I("PBUFS not available bdindex is %d ", bdindex); |
| 238 | LOG_I("instance_p->buffer.tx_pbufs_storage[bdindex] %p ", instance_p->buffer.tx_pbufs_storage[bdindex]); |
| 239 | return ERR_GENERAL; |
| 240 | } |
| 241 | |
| 242 | /* Send the data from the pbuf to the interface, one pbuf at a |
| 243 | time. The size of the data in each pbuf is kept in the ->len |
| 244 | variable. */ |
| 245 | tx_payload = (uintptr)q->payload; |
| 246 | #ifdef RT_USING_SMART |
| 247 | tx_payload += PV_OFFSET; |
| 248 | #endif |
| 249 | FXMAC_MSG_BD_SET_ADDRESS_TX(txbd, (uintptr)tx_payload); |
| 250 | |
| 251 | if (instance_p->config & FXMAC_MSG_OS_CONFIG_JUMBO) |
| 252 | { |
| 253 | max_fr_size = FXMAC_MSG_MAX_FRAME_SIZE_JUMBO; |
| 254 | } |
| 255 | else |
| 256 | { |
| 257 | max_fr_size = FXMAC_MSG_MAX_FRAME_SIZE; |
| 258 | } |
no test coverage detected