Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright(C) 2021 Marvell. 3 : : */ 4 : : 5 : : #include "cn9k_ethdev.h" 6 : : #include "cn9k_tx.h" 7 : : 8 : : #if defined(RTE_ARCH_ARM64) && !defined(CNXK_DIS_TMPLT_FUNC) 9 : : static 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 : : /* [TS] [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 : : cn9k_nix_tx_queue_count(void *tx_queue) 28 : : { 29 : : struct cn9k_eth_txq *txq = (struct cn9k_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 : : cn9k_nix_tx_queue_sec_count(void *tx_queue) 36 : : { 37 : : struct cn9k_eth_txq *txq = (struct cn9k_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 : : cn9k_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] = cn9k_nix_xmit_pkts_##name, 50 : : NIX_TX_FASTPATH_MODES 51 : : #undef T 52 : : }; 53 : : 54 : : const eth_tx_burst_t nix_eth_tx_burst_mseg[NIX_TX_OFFLOAD_MAX] = { 55 : : #define T(name, sz, flags)[flags] = cn9k_nix_xmit_pkts_mseg_##name, 56 : : NIX_TX_FASTPATH_MODES 57 : : #undef T 58 : : }; 59 : : 60 : : const eth_tx_burst_t nix_eth_tx_vec_burst[NIX_TX_OFFLOAD_MAX] = { 61 : : #define T(name, sz, flags)[flags] = cn9k_nix_xmit_pkts_vec_##name, 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] = cn9k_nix_xmit_pkts_vec_mseg_##name, 68 : : NIX_TX_FASTPATH_MODES 69 : : #undef T 70 : : }; 71 : : 72 : : if (dev->scalar_ena || dev->tx_mark) { 73 : : pick_tx_func(eth_dev, nix_eth_tx_burst); 74 : : if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS) 75 : : pick_tx_func(eth_dev, nix_eth_tx_burst_mseg); 76 : : } else { 77 : : pick_tx_func(eth_dev, nix_eth_tx_vec_burst); 78 : : if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_MULTI_SEGS) 79 : : pick_tx_func(eth_dev, nix_eth_tx_vec_burst_mseg); 80 : : } 81 : : #else 82 : : RTE_SET_USED(eth_dev); 83 : : #endif 84 : : } 85 : : 86 : : static void 87 : : cn9k_eth_set_tx_blk_func(struct rte_eth_dev *eth_dev) 88 : : { 89 : : #if defined(CNXK_DIS_TMPLT_FUNC) 90 : : struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); 91 : : struct cn9k_eth_txq *txq; 92 : : int i; 93 : : 94 : : for (i = 0; i < eth_dev->data->nb_tx_queues; i++) { 95 : : txq = (struct cn9k_eth_txq *)eth_dev->data->tx_queues[i]; 96 : : txq->tx_offload_flags = dev->tx_offload_flags; 97 : : } 98 : : 99 : : if (dev->scalar_ena || dev->tx_mark) 100 : : eth_dev->tx_pkt_burst = cn9k_nix_xmit_pkts_all_offload; 101 : : else 102 : : eth_dev->tx_pkt_burst = cn9k_nix_xmit_pkts_vec_all_offload; 103 : : 104 : : if (eth_dev->data->dev_started) 105 : : rte_eth_fp_ops[eth_dev->data->port_id].tx_pkt_burst = eth_dev->tx_pkt_burst; 106 : : #else 107 : : RTE_SET_USED(eth_dev); 108 : : #endif 109 : : } 110 : : #endif 111 : : 112 : : void 113 : 0 : cn9k_eth_set_tx_function(struct rte_eth_dev *eth_dev) 114 : : { 115 : : #if defined(RTE_ARCH_ARM64) 116 : : struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev); 117 : : 118 : : cn9k_eth_set_tx_blk_func(eth_dev); 119 : : cn9k_eth_set_tx_tmplt_func(eth_dev); 120 : : 121 : : if (dev->tx_offloads & RTE_ETH_TX_OFFLOAD_SECURITY) 122 : : eth_dev->tx_queue_count = cn9k_nix_tx_queue_sec_count; 123 : : else 124 : : eth_dev->tx_queue_count = cn9k_nix_tx_queue_count; 125 : : 126 : : rte_atomic_thread_fence(rte_memory_order_release); 127 : : #else 128 : : RTE_SET_USED(eth_dev); 129 : : #endif 130 : 0 : }