Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright(C) 2024 Marvell. 3 : : */ 4 : : 5 : : #include "cn20k_ethdev.h" 6 : : #include "cn20k_tx.h" 7 : : 8 : : #if defined(RTE_ARCH_ARM64) && !defined(CNXK_DIS_TMPLT_FUNC) 9 : : static inline void 10 : : pick_tx_func(struct rte_eth_dev *eth_dev, const eth_tx_burst_t tx_burst[NIX_TX_OFFLOAD_MAX]) 11 : : { 12 : : struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); 13 : : 14 : : /* [SEC] [TSP] [TSO] [NOFF] [VLAN] [OL3_OL4_CSUM] [IL3_IL4_CSUM] */ 15 : : eth_dev->tx_pkt_burst = tx_burst[dev->tx_offload_flags & (NIX_TX_OFFLOAD_MAX - 1)]; 16 : : 17 : : if (eth_dev->data->dev_started) 18 : : rte_eth_fp_ops[eth_dev->data->port_id].tx_pkt_burst = eth_dev->tx_pkt_burst; 19 : : } 20 : : #endif 21 : : 22 : : #if defined(RTE_ARCH_ARM64) 23 : : static int 24 : : cn20k_nix_tx_queue_count(void *tx_queue) 25 : : { 26 : : struct cn20k_eth_txq *txq = (struct cn20k_eth_txq *)tx_queue; 27 : : 28 : : return cnxk_nix_tx_queue_count(txq->fc_mem, txq->sqes_per_sqb_log2); 29 : : } 30 : : 31 : : static int 32 : : cn20k_nix_tx_queue_sec_count(void *tx_queue) 33 : : { 34 : : struct cn20k_eth_txq *txq = (struct cn20k_eth_txq *)tx_queue; 35 : : 36 : : return cnxk_nix_tx_queue_sec_count(txq->fc_mem, txq->sqes_per_sqb_log2, txq->cpt_fc); 37 : : } 38 : : 39 : : static void 40 : : cn20k_eth_set_tx_tmplt_func(struct rte_eth_dev *eth_dev) 41 : : { 42 : : #if !defined(CNXK_DIS_TMPLT_FUNC) 43 : : struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); 44 : : 45 : : const eth_tx_burst_t nix_eth_tx_burst[NIX_TX_OFFLOAD_MAX] = { 46 : : #define T(name, sz, flags) [flags] = cn20k_nix_xmit_pkts_##name, 47 : : 48 : : NIX_TX_FASTPATH_MODES 49 : : #undef T 50 : : }; 51 : : 52 : : const eth_tx_burst_t nix_eth_tx_burst_mseg[NIX_TX_OFFLOAD_MAX] = { 53 : : #define T(name, sz, flags) [flags] = cn20k_nix_xmit_pkts_mseg_##name, 54 : : 55 : : NIX_TX_FASTPATH_MODES 56 : : #undef T 57 : : }; 58 : : 59 : : const eth_tx_burst_t nix_eth_tx_vec_burst[NIX_TX_OFFLOAD_MAX] = { 60 : : #define T(name, sz, flags) [flags] = cn20k_nix_xmit_pkts_vec_##name, 61 : : 62 : : NIX_TX_FASTPATH_MODES 63 : : #undef T 64 : : }; 65 : : 66 : : const eth_tx_burst_t nix_eth_tx_vec_burst_mseg[NIX_TX_OFFLOAD_MAX] = { 67 : : #define T(name, sz, flags) [flags] = cn20k_nix_xmit_pkts_vec_mseg_##name, 68 : : 69 : : NIX_TX_FASTPATH_MODES 70 : : #undef T 71 : : }; 72 : : 73 : : if (dev->scalar_ena || dev->tx_mark) { 74 : : pick_tx_func(eth_dev, nix_eth_tx_burst); 75 : : if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS) 76 : : pick_tx_func(eth_dev, nix_eth_tx_burst_mseg); 77 : : } else { 78 : : pick_tx_func(eth_dev, nix_eth_tx_vec_burst); 79 : : if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS) 80 : : pick_tx_func(eth_dev, nix_eth_tx_vec_burst_mseg); 81 : : } 82 : : #else 83 : : RTE_SET_USED(eth_dev); 84 : : #endif 85 : : } 86 : : 87 : : static void 88 : : cn20k_eth_set_tx_blk_func(struct rte_eth_dev *eth_dev) 89 : : { 90 : : #if defined(CNXK_DIS_TMPLT_FUNC) 91 : : struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); 92 : : 93 : : if (dev->scalar_ena || dev->tx_mark) 94 : : eth_dev->tx_pkt_burst = cn20k_nix_xmit_pkts_all_offload; 95 : : else 96 : : eth_dev->tx_pkt_burst = cn20k_nix_xmit_pkts_vec_all_offload; 97 : : 98 : : if (eth_dev->data->dev_started) 99 : : rte_eth_fp_ops[eth_dev->data->port_id].tx_pkt_burst = eth_dev->tx_pkt_burst; 100 : : #else 101 : : RTE_SET_USED(eth_dev); 102 : : #endif 103 : : } 104 : : #endif 105 : : 106 : : void 107 : 0 : cn20k_eth_set_tx_function(struct rte_eth_dev *eth_dev) 108 : : { 109 : : #if defined(RTE_ARCH_ARM64) 110 : : struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); 111 : : 112 : : cn20k_eth_set_tx_blk_func(eth_dev); 113 : : cn20k_eth_set_tx_tmplt_func(eth_dev); 114 : : 115 : : if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_SECURITY) 116 : : eth_dev->tx_queue_count = cn20k_nix_tx_queue_sec_count; 117 : : else 118 : : eth_dev->tx_queue_count = cn20k_nix_tx_queue_count; 119 : : 120 : : rte_atomic_thread_fence(rte_memory_order_release); 121 : : #else 122 : : RTE_SET_USED(eth_dev); 123 : : #endif 124 : 0 : }