MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / FXmacSgsend

Function FXmacSgsend

bsp/phytium/libraries/drivers/drv_xmac.c:196–302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

FXmacOsOutputFunction · 0.85

Calls 1

pbuf_refFunction · 0.50

Tested by

no test coverage detected