* t4_eth_xmit - add a packet to an Ethernet Tx queue * @txq: the egress queue * @mbuf: the packet * * Add a packet to an SGE Ethernet Tx queue. Runs with softirqs disabled. */
| 1036 | * Add a packet to an SGE Ethernet Tx queue. Runs with softirqs disabled. |
| 1037 | */ |
| 1038 | int t4_eth_xmit(struct sge_eth_txq *txq, struct rte_mbuf *mbuf, |
| 1039 | uint16_t nb_pkts) |
| 1040 | { |
| 1041 | const struct port_info *pi; |
| 1042 | struct cpl_tx_pkt_lso_core *lso; |
| 1043 | struct adapter *adap; |
| 1044 | struct rte_mbuf *m = mbuf; |
| 1045 | struct fw_eth_tx_pkt_wr *wr; |
| 1046 | struct fw_eth_tx_pkt_vm_wr *vmwr; |
| 1047 | struct cpl_tx_pkt_core *cpl; |
| 1048 | struct tx_sw_desc *d; |
| 1049 | dma_addr_t addr[m->nb_segs]; |
| 1050 | unsigned int flits, ndesc, cflits; |
| 1051 | int l3hdr_len, l4hdr_len, eth_xtra_len; |
| 1052 | int len, last_desc; |
| 1053 | int should_coal, credits; |
| 1054 | u32 wr_mid; |
| 1055 | u64 cntrl, *end; |
| 1056 | bool v6; |
| 1057 | u32 max_pkt_len; |
| 1058 | |
| 1059 | /* Reject xmit if queue is stopped */ |
| 1060 | if (unlikely(txq->flags & EQ_STOPPED)) |
| 1061 | return -(EBUSY); |
| 1062 | |
| 1063 | /* |
| 1064 | * The chip min packet length is 10 octets but play safe and reject |
| 1065 | * anything shorter than an Ethernet header. |
| 1066 | */ |
| 1067 | if (unlikely(m->pkt_len < RTE_ETHER_HDR_LEN)) { |
| 1068 | out_free: |
| 1069 | rte_pktmbuf_free(m); |
| 1070 | return 0; |
| 1071 | } |
| 1072 | |
| 1073 | max_pkt_len = txq->data->mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN; |
| 1074 | if ((!(m->ol_flags & RTE_MBUF_F_TX_TCP_SEG)) && |
| 1075 | (unlikely(m->pkt_len > max_pkt_len))) |
| 1076 | goto out_free; |
| 1077 | |
| 1078 | pi = txq->data->dev_private; |
| 1079 | adap = pi->adapter; |
| 1080 | |
| 1081 | cntrl = F_TXPKT_L4CSUM_DIS | F_TXPKT_IPCSUM_DIS; |
| 1082 | /* align the end of coalesce WR to a 512 byte boundary */ |
| 1083 | txq->q.coalesce.max = (8 - (txq->q.pidx & 7)) * 8; |
| 1084 | |
| 1085 | if ((m->ol_flags & RTE_MBUF_F_TX_TCP_SEG) == 0) { |
| 1086 | should_coal = should_tx_packet_coalesce(txq, mbuf, &cflits, adap); |
| 1087 | if (should_coal > 0) { |
| 1088 | if (unlikely(map_mbuf(mbuf, addr) < 0)) { |
| 1089 | dev_warn(adap, "%s: mapping err for coalesce\n", |
| 1090 | __func__); |
| 1091 | txq->stats.mapping_err++; |
| 1092 | goto out_free; |
| 1093 | } |
| 1094 | return tx_do_packet_coalesce(txq, mbuf, cflits, adap, |
| 1095 | pi, addr, nb_pkts); |
no test coverage detected