Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright(C) 2022 Marvell. 3 : : */ 4 : : #ifndef __CNXK_ETHDEV_DP_H__ 5 : : #define __CNXK_ETHDEV_DP_H__ 6 : : 7 : : #include <rte_security_driver.h> 8 : : #include <rte_mbuf.h> 9 : : 10 : : /* If PTP is enabled additional SEND MEM DESC is required which 11 : : * takes 2 words, hence max 7 iova address are possible 12 : : */ 13 : : #if defined(RTE_LIBRTE_IEEE1588) 14 : : #define CNXK_NIX_TX_NB_SEG_MAX 7 15 : : #else 16 : : #define CNXK_NIX_TX_NB_SEG_MAX 9 17 : : #endif 18 : : 19 : : #define CNXK_NIX_TX_MSEG_SG_DWORDS \ 20 : : ((RTE_ALIGN_MUL_CEIL(CNXK_NIX_TX_NB_SEG_MAX, 3) / 3) + \ 21 : : CNXK_NIX_TX_NB_SEG_MAX) 22 : : 23 : : /* Default mark value used when none is provided. */ 24 : : #define CNXK_FLOW_ACTION_FLAG_DEFAULT 0xffff 25 : : #define CNXK_NIX_TIMESYNC_RX_OFFSET 8 26 : : 27 : : #define PTYPE_NON_TUNNEL_WIDTH 16 28 : : #define PTYPE_TUNNEL_WIDTH 12 29 : : #define PTYPE_NON_TUNNEL_ARRAY_SZ BIT(PTYPE_NON_TUNNEL_WIDTH) 30 : : #define PTYPE_TUNNEL_ARRAY_SZ BIT(PTYPE_TUNNEL_WIDTH) 31 : : #define PTYPE_ARRAY_SZ \ 32 : : ((PTYPE_NON_TUNNEL_ARRAY_SZ + PTYPE_TUNNEL_ARRAY_SZ) * sizeof(uint16_t)) 33 : : 34 : : /* NIX_RX_PARSE_S's ERRCODE + ERRLEV (12 bits) */ 35 : : #define ERRCODE_ERRLEN_WIDTH 12 36 : : #define ERR_ARRAY_SZ ((BIT(ERRCODE_ERRLEN_WIDTH)) * sizeof(uint32_t)) 37 : : 38 : : #define SA_BASE_TBL_SZ (RTE_MAX_ETHPORTS * sizeof(uintptr_t)) 39 : : #define MEMPOOL_TBL_SZ (RTE_MAX_ETHPORTS * sizeof(uintptr_t)) 40 : : 41 : : #define CNXK_NIX_UDP_TUN_BITMASK \ 42 : : ((1ull << (RTE_MBUF_F_TX_TUNNEL_VXLAN >> 45)) | \ 43 : : (1ull << (RTE_MBUF_F_TX_TUNNEL_GENEVE >> 45))) 44 : : 45 : : /* Subtype from inline outbound error event */ 46 : : #define CNXK_ETHDEV_SEC_OUTB_EV_SUB 0xFFUL 47 : : 48 : : /* SPI will be in 20 bits of tag */ 49 : : #define CNXK_ETHDEV_SPI_TAG_MASK 0xFFFFFUL 50 : : 51 : : #define CNXK_NIX_PFC_CHAN_COUNT 16 52 : : 53 : : #define CNXK_TM_MARK_VLAN_DEI BIT_ULL(0) 54 : : #define CNXK_TM_MARK_IP_DSCP BIT_ULL(1) 55 : : #define CNXK_TM_MARK_IP_ECN BIT_ULL(2) 56 : : 57 : : #define CNXK_TM_MARK_MASK \ 58 : : (CNXK_TM_MARK_VLAN_DEI | CNXK_TM_MARK_IP_DSCP | CNXK_TM_MARK_IP_ECN) 59 : : 60 : : #define CNXK_TX_MARK_FMT_MASK (0xFFFFFFFFFFFFull) 61 : : 62 : : struct cnxk_eth_txq_comp { 63 : : uintptr_t desc_base; 64 : : uintptr_t cq_door; 65 : : int64_t *cq_status; 66 : : uint64_t wdata; 67 : : uint32_t head; 68 : : uint32_t qmask; 69 : : uint32_t nb_desc_mask; 70 : : uint32_t available; 71 : : uint32_t sqe_id; 72 : : bool ena; 73 : : struct rte_mbuf **ptr; 74 : : rte_spinlock_t ext_buf_lock; 75 : : }; 76 : : 77 : : struct cnxk_timesync_info { 78 : : uint8_t rx_ready; 79 : : uint64_t rx_tstamp; 80 : : uint64_t rx_tstamp_dynflag; 81 : : int tstamp_dynfield_offset; 82 : : rte_iova_t tx_tstamp_iova; 83 : : uint64_t *tx_tstamp; 84 : : } __plt_cache_aligned; 85 : : 86 : : struct cnxk_ethdev_inj_cfg { 87 : : uintptr_t lmt_base; 88 : : uint64_t io_addr; 89 : : uint64_t sa_base; 90 : : uint64_t cmd_w0; 91 : : } __plt_cache_aligned; 92 : : 93 : : /* Inlines */ 94 : : static __rte_always_inline uint64_t 95 : : cnxk_pktmbuf_detach(struct rte_mbuf *m, uint64_t *aura) 96 : : { 97 : : struct rte_mempool *mp = m->pool; 98 : : uint32_t mbuf_size, buf_len; 99 : : struct rte_mbuf *md; 100 : : uint16_t priv_size; 101 : : uint16_t refcount; 102 : : 103 : : /* Update refcount of direct mbuf */ 104 : : md = rte_mbuf_from_indirect(m); 105 : : if (aura) 106 : : *aura = roc_npa_aura_handle_to_aura(md->pool->pool_id); 107 : : refcount = rte_mbuf_refcnt_update(md, -1); 108 : : 109 : : priv_size = rte_pktmbuf_priv_size(mp); 110 : : mbuf_size = (uint32_t)(sizeof(struct rte_mbuf) + priv_size); 111 : : buf_len = rte_pktmbuf_data_room_size(mp); 112 : : 113 : : m->priv_size = priv_size; 114 : : m->buf_addr = (char *)m + mbuf_size; 115 : : rte_mbuf_iova_set(m, rte_mempool_virt2iova(m) + mbuf_size); 116 : : m->buf_len = (uint16_t)buf_len; 117 : : rte_pktmbuf_reset_headroom(m); 118 : : m->data_len = 0; 119 : : m->ol_flags = 0; 120 : : m->next = NULL; 121 : : m->nb_segs = 1; 122 : : 123 : : /* Now indirect mbuf is safe to free */ 124 : : rte_pktmbuf_free(m); 125 : : 126 : : if (refcount == 0) { 127 : : rte_mbuf_refcnt_set(md, 1); 128 : : md->data_len = 0; 129 : : md->ol_flags = 0; 130 : : md->next = NULL; 131 : : md->nb_segs = 1; 132 : : return 0; 133 : : } else { 134 : : return 1; 135 : : } 136 : : } 137 : : 138 : : static __rte_always_inline uint64_t 139 : : cnxk_nix_prefree_seg(struct rte_mbuf *m, uint64_t *aura) 140 : : { 141 : : if (likely(rte_mbuf_refcnt_read(m) == 1)) { 142 : : if (!RTE_MBUF_DIRECT(m)) 143 : : return cnxk_pktmbuf_detach(m, aura); 144 : : 145 : : m->next = NULL; 146 : : m->nb_segs = 1; 147 : : return 0; 148 : : } else if (rte_mbuf_refcnt_update(m, -1) == 0) { 149 : : if (!RTE_MBUF_DIRECT(m)) 150 : : return cnxk_pktmbuf_detach(m, aura); 151 : : 152 : : rte_mbuf_refcnt_set(m, 1); 153 : : m->next = NULL; 154 : : m->nb_segs = 1; 155 : : return 0; 156 : : } 157 : : 158 : : /* Mbuf is having refcount more than 1 so need not to be freed */ 159 : : return 1; 160 : : } 161 : : 162 : : static inline rte_mbuf_timestamp_t * 163 : : cnxk_nix_timestamp_dynfield(struct rte_mbuf *mbuf, 164 : : struct cnxk_timesync_info *info) 165 : : { 166 [ # # ]: 0 : return RTE_MBUF_DYNFIELD(mbuf, info->tstamp_dynfield_offset, 167 : : rte_mbuf_timestamp_t *); 168 : : } 169 : : 170 : : static __rte_always_inline uintptr_t 171 : : cnxk_nix_sa_base_get(uint16_t port, const void *lookup_mem) 172 : : { 173 : : uintptr_t sa_base_tbl; 174 : : 175 : 0 : sa_base_tbl = (uintptr_t)lookup_mem; 176 : 0 : sa_base_tbl += PTYPE_ARRAY_SZ + ERR_ARRAY_SZ; 177 [ # # # # : 0 : return *((const uintptr_t *)sa_base_tbl + port); # # ] 178 : : } 179 : : 180 : : static __rte_always_inline uintptr_t 181 : : cnxk_nix_inl_metapool_get(uint16_t port, const void *lookup_mem) 182 : : { 183 : : uintptr_t metapool_tbl; 184 : : 185 : 0 : metapool_tbl = (uintptr_t)lookup_mem; 186 : 0 : metapool_tbl += PTYPE_ARRAY_SZ + ERR_ARRAY_SZ + SA_BASE_TBL_SZ; 187 [ # # # # : 0 : return *((const uintptr_t *)metapool_tbl + port); # # # # # # # # ] 188 : : } 189 : : 190 : : #endif /* __CNXK_ETHDEV_DP_H__ */