MCPcopy Create free account
hub / github.com/F-Stack/f-stack / calc_tx_flits

Function calc_tx_flits

dpdk/drivers/net/cxgbe/sge.c:492–527  ·  view source on GitHub ↗

* calc_tx_flits - calculate the number of flits for a packet Tx WR * @m: the packet * @adap: adapter structure pointer * * Returns the number of flits needed for a Tx WR for the given Ethernet * packet, including the needed WR and CPL headers. */

Source from the content-addressed store, hash-verified

490 * packet, including the needed WR and CPL headers.
491 */
492static inline unsigned int calc_tx_flits(const struct rte_mbuf *m,
493 struct adapter *adap)
494{
495 size_t wr_size = is_pf4(adap) ? sizeof(struct fw_eth_tx_pkt_wr) :
496 sizeof(struct fw_eth_tx_pkt_vm_wr);
497 unsigned int flits;
498 int hdrlen;
499
500 /*
501 * If the mbuf is small enough, we can pump it out as a work request
502 * with only immediate data. In that case we just have to have the
503 * TX Packet header plus the mbuf data in the Work Request.
504 */
505
506 hdrlen = is_eth_imm(m);
507 if (hdrlen)
508 return DIV_ROUND_UP(m->pkt_len + hdrlen, sizeof(__be64));
509
510 /*
511 * Otherwise, we're going to have to construct a Scatter gather list
512 * of the mbuf body and fragments. We also include the flits necessary
513 * for the TX Packet Work Request and CPL. We always have a firmware
514 * Write Header (incorporated as part of the cpl_tx_pkt_lso and
515 * cpl_tx_pkt structures), followed by either a TX Packet Write CPL
516 * message or, if we're doing a Large Send Offload, an LSO CPL message
517 * with an embedded TX Packet Write CPL message.
518 */
519 flits = sgl_len(m->nb_segs);
520 if (m->tso_segsz)
521 flits += (wr_size + sizeof(struct cpl_tx_pkt_lso_core) +
522 sizeof(struct cpl_tx_pkt_core)) / sizeof(__be64);
523 else
524 flits += (wr_size +
525 sizeof(struct cpl_tx_pkt_core)) / sizeof(__be64);
526 return flits;
527}
528
529/**
530 * write_sgl - populate a scatter/gather list for a packet

Callers 1

t4_eth_xmitFunction · 0.85

Calls 3

is_pf4Function · 0.85
is_eth_immFunction · 0.85
sgl_lenFunction · 0.85

Tested by

no test coverage detected