1d81734caSHemant Agrawal /* SPDX-License-Identifier: BSD-3-Clause 2ff9e112dSShreyansh Jain * 3ff9e112dSShreyansh Jain * Copyright (c) 2014-2016 Freescale Semiconductor, Inc. All rights reserved. 4f513f620SSachin Saxena * Copyright 2017-2019 NXP 5ff9e112dSShreyansh Jain * 6ff9e112dSShreyansh Jain */ 7ff9e112dSShreyansh Jain #ifndef __DPAA_ETHDEV_H__ 8ff9e112dSShreyansh Jain #define __DPAA_ETHDEV_H__ 9ff9e112dSShreyansh Jain 10ff9e112dSShreyansh Jain /* System headers */ 11ff9e112dSShreyansh Jain #include <stdbool.h> 12ffc905f3SFerruh Yigit #include <rte_ethdev_driver.h> 135e745593SSunil Kumar Kori #include <rte_event_eth_rx_adapter.h> 14ff9e112dSShreyansh Jain 15ff9e112dSShreyansh Jain #include <fsl_usd.h> 16ff9e112dSShreyansh Jain #include <fsl_qman.h> 17ff9e112dSShreyansh Jain #include <fsl_bman.h> 188c83f28cSHemant Agrawal #include <dpaa_of.h> 19ff9e112dSShreyansh Jain #include <netcfg.h> 20ff9e112dSShreyansh Jain 21af2828cfSAkhil Goyal #define MAX_DPAA_CORES 4 22ff9e112dSShreyansh Jain #define DPAA_MBUF_HW_ANNOTATION 64 23ff9e112dSShreyansh Jain #define DPAA_FD_PTA_SIZE 64 24ff9e112dSShreyansh Jain 255e745593SSunil Kumar Kori /* mbuf->seqn will be used to store event entry index for 265e745593SSunil Kumar Kori * driver specific usage. For parallel mode queues, invalid 275e745593SSunil Kumar Kori * index will be set and for atomic mode queues, valid value 285e745593SSunil Kumar Kori * ranging from 1 to 16. 295e745593SSunil Kumar Kori */ 305e745593SSunil Kumar Kori #define DPAA_INVALID_MBUF_SEQN 0 315e745593SSunil Kumar Kori 32ff9e112dSShreyansh Jain /* we will re-use the HEADROOM for annotation in RX */ 33ff9e112dSShreyansh Jain #define DPAA_HW_BUF_RESERVE 0 34ff9e112dSShreyansh Jain #define DPAA_PACKET_LAYOUT_ALIGN 64 35ff9e112dSShreyansh Jain 36ff9e112dSShreyansh Jain /* Alignment to use for cpu-local structs to avoid coherency problems. */ 37ff9e112dSShreyansh Jain #define MAX_CACHELINE 64 38ff9e112dSShreyansh Jain 39ff9e112dSShreyansh Jain #define DPAA_MAX_RX_PKT_LEN 10240 40ff9e112dSShreyansh Jain 4155576ac2SHemant Agrawal #define DPAA_SGT_MAX_ENTRIES 16 /* maximum number of entries in SG Table */ 4255576ac2SHemant Agrawal 4362f53995SHemant Agrawal /* RX queue tail drop threshold (CGR Based) in frame count */ 4462f53995SHemant Agrawal #define CGR_RX_PERFQ_THRESH 256 45e35ead33SHemant Agrawal #define CGR_TX_CGR_THRESH 512 46ff9e112dSShreyansh Jain 47ff9e112dSShreyansh Jain /*max mac filter for memac(8) including primary mac addr*/ 48ff9e112dSShreyansh Jain #define DPAA_MAX_MAC_FILTER (MEMAC_NUM_OF_PADDRS + 1) 49ff9e112dSShreyansh Jain 50ff9e112dSShreyansh Jain /*Maximum number of slots available in TX ring*/ 51b0a87fe2SNipun Gupta #define DPAA_TX_BURST_SIZE 7 52ff9e112dSShreyansh Jain 532c01a48aSShreyansh Jain /* Optimal burst size for RX and TX as default */ 542c01a48aSShreyansh Jain #define DPAA_DEF_RX_BURST_SIZE 7 552c01a48aSShreyansh Jain #define DPAA_DEF_TX_BURST_SIZE DPAA_TX_BURST_SIZE 562c01a48aSShreyansh Jain 579658ac3aSAshish Jain #ifndef VLAN_TAG_SIZE 589658ac3aSAshish Jain #define VLAN_TAG_SIZE 4 /** < Vlan Header Length */ 599658ac3aSAshish Jain #endif 609658ac3aSAshish Jain 61ff9e112dSShreyansh Jain /* PCD frame queues */ 62ff9e112dSShreyansh Jain #define DPAA_PCD_FQID_START 0x400 63ff9e112dSShreyansh Jain #define DPAA_PCD_FQID_MULTIPLIER 0x100 64ff9e112dSShreyansh Jain #define DPAA_DEFAULT_NUM_PCD_QUEUES 1 65f04e7139SHemant Agrawal #define DPAA_MAX_NUM_PCD_QUEUES 4 66ff9e112dSShreyansh Jain 67ff9e112dSShreyansh Jain #define DPAA_IF_TX_PRIORITY 3 680c504f69SHemant Agrawal #define DPAA_IF_RX_PRIORITY 0 69ff9e112dSShreyansh Jain #define DPAA_IF_DEBUG_PRIORITY 7 70ff9e112dSShreyansh Jain 71ff9e112dSShreyansh Jain #define DPAA_IF_RX_ANNOTATION_STASH 1 72ff9e112dSShreyansh Jain #define DPAA_IF_RX_DATA_STASH 1 73ff9e112dSShreyansh Jain #define DPAA_IF_RX_CONTEXT_STASH 0 74ff9e112dSShreyansh Jain 75ff9e112dSShreyansh Jain /* Each "debug" FQ is represented by one of these */ 76ff9e112dSShreyansh Jain #define DPAA_DEBUG_FQ_RX_ERROR 0 77ff9e112dSShreyansh Jain #define DPAA_DEBUG_FQ_TX_ERROR 1 78ff9e112dSShreyansh Jain 794fa5e0bbSShreyansh Jain #define DPAA_RSS_OFFLOAD_ALL ( \ 80dce2f7ceSNipun Gupta ETH_RSS_L2_PAYLOAD | \ 81dce2f7ceSNipun Gupta ETH_RSS_IP | \ 82dce2f7ceSNipun Gupta ETH_RSS_UDP | \ 83dce2f7ceSNipun Gupta ETH_RSS_TCP | \ 84dce2f7ceSNipun Gupta ETH_RSS_SCTP) 854fa5e0bbSShreyansh Jain 86ff9e112dSShreyansh Jain #define DPAA_TX_CKSUM_OFFLOAD_MASK ( \ 87ff9e112dSShreyansh Jain PKT_TX_IP_CKSUM | \ 88ff9e112dSShreyansh Jain PKT_TX_TCP_CKSUM | \ 89ff9e112dSShreyansh Jain PKT_TX_UDP_CKSUM) 90ff9e112dSShreyansh Jain 91ff9e112dSShreyansh Jain /* DPAA Frame descriptor macros */ 92ff9e112dSShreyansh Jain 93ff9e112dSShreyansh Jain #define DPAA_FD_CMD_FCO 0x80000000 94ff9e112dSShreyansh Jain /**< Frame queue Context Override */ 95ff9e112dSShreyansh Jain #define DPAA_FD_CMD_RPD 0x40000000 96ff9e112dSShreyansh Jain /**< Read Prepended Data */ 97ff9e112dSShreyansh Jain #define DPAA_FD_CMD_UPD 0x20000000 98ff9e112dSShreyansh Jain /**< Update Prepended Data */ 99ff9e112dSShreyansh Jain #define DPAA_FD_CMD_DTC 0x10000000 100ff9e112dSShreyansh Jain /**< Do IP/TCP/UDP Checksum */ 101ff9e112dSShreyansh Jain #define DPAA_FD_CMD_DCL4C 0x10000000 102ff9e112dSShreyansh Jain /**< Didn't calculate L4 Checksum */ 103ff9e112dSShreyansh Jain #define DPAA_FD_CMD_CFQ 0x00ffffff 104ff9e112dSShreyansh Jain /**< Confirmation Frame Queue */ 105ff9e112dSShreyansh Jain 106ff9e112dSShreyansh Jain /* Each network interface is represented by one of these */ 107ff9e112dSShreyansh Jain struct dpaa_if { 108ff9e112dSShreyansh Jain int valid; 109ff9e112dSShreyansh Jain char *name; 110ff9e112dSShreyansh Jain const struct fm_eth_port_cfg *cfg; 111ff9e112dSShreyansh Jain struct qman_fq *rx_queues; 11262f53995SHemant Agrawal struct qman_cgr *cgr_rx; 113ff9e112dSShreyansh Jain struct qman_fq *tx_queues; 114*9124e65dSGagandeep Singh struct qman_cgr *cgr_tx; 115ff9e112dSShreyansh Jain struct qman_fq debug_queues[2]; 116ff9e112dSShreyansh Jain uint16_t nb_rx_queues; 117ff9e112dSShreyansh Jain uint16_t nb_tx_queues; 118ff9e112dSShreyansh Jain uint32_t ifid; 119ff9e112dSShreyansh Jain struct fman_if *fif; 120ff9e112dSShreyansh Jain struct dpaa_bp_info *bp_info; 121ff9e112dSShreyansh Jain struct rte_eth_fc_conf *fc_conf; 122ff9e112dSShreyansh Jain }; 123ff9e112dSShreyansh Jain 124b21ed3e2SHemant Agrawal struct dpaa_if_stats { 125b21ed3e2SHemant Agrawal /* Rx Statistics Counter */ 126b21ed3e2SHemant Agrawal uint64_t reoct; /**<Rx Eth Octets Counter */ 127b21ed3e2SHemant Agrawal uint64_t roct; /**<Rx Octet Counters */ 128b21ed3e2SHemant Agrawal uint64_t raln; /**<Rx Alignment Error Counter */ 129b21ed3e2SHemant Agrawal uint64_t rxpf; /**<Rx valid Pause Frame */ 130b21ed3e2SHemant Agrawal uint64_t rfrm; /**<Rx Frame counter */ 131b21ed3e2SHemant Agrawal uint64_t rfcs; /**<Rx frame check seq error */ 132b21ed3e2SHemant Agrawal uint64_t rvlan; /**<Rx Vlan Frame Counter */ 133b21ed3e2SHemant Agrawal uint64_t rerr; /**<Rx Frame error */ 134b21ed3e2SHemant Agrawal uint64_t ruca; /**<Rx Unicast */ 135b21ed3e2SHemant Agrawal uint64_t rmca; /**<Rx Multicast */ 136b21ed3e2SHemant Agrawal uint64_t rbca; /**<Rx Broadcast */ 137b21ed3e2SHemant Agrawal uint64_t rdrp; /**<Rx Dropped Packet */ 138b21ed3e2SHemant Agrawal uint64_t rpkt; /**<Rx packet */ 139b21ed3e2SHemant Agrawal uint64_t rund; /**<Rx undersized packets */ 140b21ed3e2SHemant Agrawal uint32_t res_x[14]; 141b21ed3e2SHemant Agrawal uint64_t rovr; /**<Rx oversized but good */ 142b21ed3e2SHemant Agrawal uint64_t rjbr; /**<Rx oversized with bad csum */ 143b21ed3e2SHemant Agrawal uint64_t rfrg; /**<Rx fragment Packet */ 144b21ed3e2SHemant Agrawal uint64_t rcnp; /**<Rx control packets (0x8808 */ 145b21ed3e2SHemant Agrawal uint64_t rdrntp; /**<Rx dropped due to FIFO overflow */ 146b21ed3e2SHemant Agrawal uint32_t res01d0[12]; 147b21ed3e2SHemant Agrawal /* Tx Statistics Counter */ 148b21ed3e2SHemant Agrawal uint64_t teoct; /**<Tx eth octets */ 149b21ed3e2SHemant Agrawal uint64_t toct; /**<Tx Octets */ 150b21ed3e2SHemant Agrawal uint32_t res0210[2]; 151b21ed3e2SHemant Agrawal uint64_t txpf; /**<Tx valid pause frame */ 152b21ed3e2SHemant Agrawal uint64_t tfrm; /**<Tx frame counter */ 153b21ed3e2SHemant Agrawal uint64_t tfcs; /**<Tx FCS error */ 154b21ed3e2SHemant Agrawal uint64_t tvlan; /**<Tx Vlan Frame */ 155b21ed3e2SHemant Agrawal uint64_t terr; /**<Tx frame error */ 156b21ed3e2SHemant Agrawal uint64_t tuca; /**<Tx Unicast */ 157b21ed3e2SHemant Agrawal uint64_t tmca; /**<Tx Multicast */ 158b21ed3e2SHemant Agrawal uint64_t tbca; /**<Tx Broadcast */ 159b21ed3e2SHemant Agrawal uint32_t res0258[2]; 160b21ed3e2SHemant Agrawal uint64_t tpkt; /**<Tx Packet */ 161b21ed3e2SHemant Agrawal uint64_t tund; /**<Tx Undersized */ 162b21ed3e2SHemant Agrawal }; 163b21ed3e2SHemant Agrawal 1646b6ca751SHemant Agrawal __rte_internal 1651e06b6dcSHemant Agrawal int 1661e06b6dcSHemant Agrawal dpaa_eth_eventq_attach(const struct rte_eth_dev *dev, 1675e745593SSunil Kumar Kori int eth_rx_queue_id, 1685e745593SSunil Kumar Kori u16 ch_id, 1695e745593SSunil Kumar Kori const struct rte_event_eth_rx_adapter_queue_conf *queue_conf); 1705e745593SSunil Kumar Kori 1716b6ca751SHemant Agrawal __rte_internal 1721e06b6dcSHemant Agrawal int 1731e06b6dcSHemant Agrawal dpaa_eth_eventq_detach(const struct rte_eth_dev *dev, 1745e745593SSunil Kumar Kori int eth_rx_queue_id); 1755e745593SSunil Kumar Kori 1765e745593SSunil Kumar Kori enum qman_cb_dqrr_result 1775e745593SSunil Kumar Kori dpaa_rx_cb_parallel(void *event, 1785e745593SSunil Kumar Kori struct qman_portal *qm __always_unused, 1795e745593SSunil Kumar Kori struct qman_fq *fq, 1805e745593SSunil Kumar Kori const struct qm_dqrr_entry *dqrr, 1815e745593SSunil Kumar Kori void **bufs); 1825e745593SSunil Kumar Kori enum qman_cb_dqrr_result 1835e745593SSunil Kumar Kori dpaa_rx_cb_atomic(void *event, 1845e745593SSunil Kumar Kori struct qman_portal *qm __always_unused, 1855e745593SSunil Kumar Kori struct qman_fq *fq, 1865e745593SSunil Kumar Kori const struct qm_dqrr_entry *dqrr, 1875e745593SSunil Kumar Kori void **bufs); 1885e745593SSunil Kumar Kori 189df80d4f8SHemant Agrawal /* PMD related logs */ 190df80d4f8SHemant Agrawal extern int dpaa_logtype_pmd; 191df80d4f8SHemant Agrawal 192df80d4f8SHemant Agrawal #define DPAA_PMD_LOG(level, fmt, args...) \ 193df80d4f8SHemant Agrawal rte_log(RTE_LOG_ ## level, dpaa_logtype_pmd, "%s(): " fmt "\n", \ 194df80d4f8SHemant Agrawal __func__, ##args) 195df80d4f8SHemant Agrawal 196df80d4f8SHemant Agrawal #define PMD_INIT_FUNC_TRACE() DPAA_PMD_LOG(DEBUG, " >>") 197df80d4f8SHemant Agrawal 198df80d4f8SHemant Agrawal #define DPAA_PMD_DEBUG(fmt, args...) \ 199df80d4f8SHemant Agrawal DPAA_PMD_LOG(DEBUG, fmt, ## args) 200df80d4f8SHemant Agrawal #define DPAA_PMD_ERR(fmt, args...) \ 201df80d4f8SHemant Agrawal DPAA_PMD_LOG(ERR, fmt, ## args) 202df80d4f8SHemant Agrawal #define DPAA_PMD_INFO(fmt, args...) \ 203df80d4f8SHemant Agrawal DPAA_PMD_LOG(INFO, fmt, ## args) 204df80d4f8SHemant Agrawal #define DPAA_PMD_WARN(fmt, args...) \ 205df80d4f8SHemant Agrawal DPAA_PMD_LOG(WARNING, fmt, ## args) 206df80d4f8SHemant Agrawal 207df80d4f8SHemant Agrawal /* DP Logs, toggled out at compile time if level lower than current level */ 208df80d4f8SHemant Agrawal #define DPAA_DP_LOG(level, fmt, args...) \ 209df80d4f8SHemant Agrawal RTE_LOG_DP(level, PMD, fmt, ## args) 210df80d4f8SHemant Agrawal 211ff9e112dSShreyansh Jain #endif 212