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