1616#include <dev_octeon/octeon.h>
1717#include <dev_octeon/ipsec.h>
1818
19+ #define OCT_TX_NODE (1 << 0)
20+ #define OCT_TX_IPSEC_TM_NODE (1 << 1)
21+
1922#define OCT_LMT_GET_LINE_ADDR (lmt_addr , lmt_num ) \
2023 (void *) ((u64) (lmt_addr) + ((u64) (lmt_num) << ROC_LMT_LINE_SIZE_LOG2))
2124
@@ -47,7 +50,8 @@ typedef struct
4750
4851#ifdef PLATFORM_OCTEON9
4952static_always_inline u32
50- oct_batch_free (vlib_main_t * vm , oct_tx_ctx_t * ctx , vnet_dev_tx_queue_t * txq )
53+ oct_batch_free (vlib_main_t * vm , oct_tx_ctx_t * ctx , vnet_dev_tx_queue_t * txq ,
54+ const u64 flags )
5155{
5256 oct_txq_t * ctq = vnet_dev_get_tx_queue_data (txq );
5357 u16 off = ctq -> hdr_off ;
@@ -61,6 +65,8 @@ oct_batch_free (vlib_main_t *vm, oct_tx_ctx_t *ctx, vnet_dev_tx_queue_t *txq)
6165 u64 buffers [n ];
6266 u32 bi [n ];
6367
68+ if (flags & OCT_TX_NODE )
69+ n = clib_min (n , ctq -> n_enq );
6470 n_freed = roc_npa_aura_op_bulk_alloc (ah , buffers , n , 0 , 1 );
6571 vlib_get_buffer_indices_with_offset (vm , (void * * ) & buffers , bi , n_freed ,
6672 off );
@@ -84,13 +90,19 @@ oct_lmt_copy (void *lmt_addr, u64 io_addr, void *desc, u64 dwords)
8490}
8591#else
8692static_always_inline u32
87- oct_batch_free (vlib_main_t * vm , oct_tx_ctx_t * ctx , vnet_dev_tx_queue_t * txq )
93+ oct_batch_free (vlib_main_t * vm , oct_tx_ctx_t * ctx , vnet_dev_tx_queue_t * txq ,
94+ const u64 flags )
8895{
8996 oct_txq_t * ctq = vnet_dev_get_tx_queue_data (txq );
97+ oct_npa_batch_alloc_cl128_t * cl ;
98+ u32 n_freed = 0 , n , n_alloc ;
9099 u8 num_cl ;
91100 u64 ah ;
92- u32 n_freed = 0 , n ;
93- oct_npa_batch_alloc_cl128_t * cl ;
101+
102+ if (flags & OCT_TX_NODE )
103+ n_alloc = clib_min (ctq -> n_enq , ROC_CN10K_NPA_BATCH_ALLOC_MAX_PTRS );
104+ else
105+ n_alloc = ROC_CN10K_NPA_BATCH_ALLOC_MAX_PTRS ;
94106
95107 num_cl = ctq -> ba_num_cl ;
96108 if (num_cl )
@@ -162,7 +174,7 @@ oct_batch_free (vlib_main_t *vm, oct_tx_ctx_t *ctx, vnet_dev_tx_queue_t *txq)
162174 {
163175 u64 addr , res ;
164176
165- n = clib_min (n , ROC_CN10K_NPA_BATCH_ALLOC_MAX_PTRS );
177+ n = clib_min (n , n_alloc );
166178
167179 oct_npa_batch_alloc_compare_t cmp = {
168180 .compare_s = { .aura = roc_npa_aura_handle_to_aura (ah ),
@@ -1690,7 +1702,7 @@ VNET_DEV_NODE_FN (oct_tx_ipsec_tm_node)
16901702 .lmt_lines = ctq -> lmt_addr + (lmt_id << ROC_LMT_LINE_SIZE_LOG2 ),
16911703 };
16921704
1693- oct_batch_free (vm , & ctx , txq );
1705+ oct_batch_free (vm , & ctx , txq , OCT_TX_IPSEC_TM_NODE );
16941706
16951707 vlib_get_buffers (vm , vlib_frame_vector_args (frame ), b , n_pkts );
16961708 n_left = n_pkts ;
@@ -1759,7 +1771,7 @@ VNET_DEV_NODE_FN (oct_tx_node)
17591771 vnet_dev_tx_queue_lock_if_needed (txq );
17601772
17611773 n_enq = ctq -> n_enq ;
1762- n_enq -= oct_batch_free (vm , & ctx , txq );
1774+ n_enq -= oct_batch_free (vm , & ctx , txq , OCT_TX_NODE );
17631775
17641776 if (PREDICT_FALSE (node -> flags & VLIB_NODE_FLAG_TRACE ))
17651777 {
0 commit comments