2022-10-18 19:41:03 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
2022-10-18 19:41:01 +00:00
|
|
|
* Copyright 2018-2022 Advanced Micro Devices, Inc.
|
2020-01-19 15:53:44 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _IONIC_LIF_H_
|
|
|
|
#define _IONIC_LIF_H_
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
|
|
|
#include <rte_ethdev.h>
|
|
|
|
#include <rte_ether.h>
|
|
|
|
|
|
|
|
#include "ionic_osdep.h"
|
|
|
|
#include "ionic_dev.h"
|
2020-01-19 15:53:49 +00:00
|
|
|
#include "ionic_rx_filter.h"
|
2020-01-19 15:53:44 +00:00
|
|
|
|
2020-01-19 15:53:46 +00:00
|
|
|
#define IONIC_ADMINQ_LENGTH 16 /* must be a power of two */
|
2020-01-19 15:53:47 +00:00
|
|
|
#define IONIC_NOTIFYQ_LENGTH 64 /* must be a power of two */
|
2020-01-19 15:53:46 +00:00
|
|
|
|
2022-10-18 19:41:18 +00:00
|
|
|
#define IONIC_MBUF_BULK_ALLOC 64 /* Multiple of 4 */
|
|
|
|
|
2020-01-19 15:53:52 +00:00
|
|
|
#define IONIC_RSS_OFFLOAD_ALL ( \
|
|
|
|
IONIC_RSS_TYPE_IPV4 | \
|
|
|
|
IONIC_RSS_TYPE_IPV4_TCP | \
|
|
|
|
IONIC_RSS_TYPE_IPV4_UDP | \
|
|
|
|
IONIC_RSS_TYPE_IPV6 | \
|
|
|
|
IONIC_RSS_TYPE_IPV6_TCP | \
|
|
|
|
IONIC_RSS_TYPE_IPV6_UDP)
|
|
|
|
|
2020-01-19 15:53:51 +00:00
|
|
|
#define IONIC_GET_SG_CNTR_IDX(num_sg_elems) (num_sg_elems)
|
|
|
|
|
|
|
|
struct ionic_tx_stats {
|
|
|
|
uint64_t packets;
|
|
|
|
uint64_t bytes;
|
|
|
|
uint64_t drop;
|
|
|
|
uint64_t stop;
|
2020-01-19 15:53:54 +00:00
|
|
|
uint64_t no_csum;
|
2020-01-19 15:53:51 +00:00
|
|
|
uint64_t tso;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ionic_rx_stats {
|
|
|
|
uint64_t packets;
|
|
|
|
uint64_t bytes;
|
|
|
|
uint64_t bad_cq_status;
|
|
|
|
uint64_t bad_len;
|
2021-02-16 20:35:35 +00:00
|
|
|
uint64_t mtods;
|
2020-01-19 15:53:51 +00:00
|
|
|
};
|
|
|
|
|
2020-01-19 15:53:46 +00:00
|
|
|
#define IONIC_QCQ_F_INITED BIT(0)
|
|
|
|
#define IONIC_QCQ_F_SG BIT(1)
|
2020-12-10 02:57:34 +00:00
|
|
|
#define IONIC_QCQ_F_DEFERRED BIT(4)
|
2022-10-18 19:41:24 +00:00
|
|
|
#define IONIC_QCQ_F_CMB BIT(5)
|
2021-01-18 20:35:06 +00:00
|
|
|
#define IONIC_QCQ_F_CSUM_L3 BIT(7)
|
|
|
|
#define IONIC_QCQ_F_CSUM_UDP BIT(8)
|
|
|
|
#define IONIC_QCQ_F_CSUM_TCP BIT(9)
|
2022-10-18 19:41:17 +00:00
|
|
|
#define IONIC_QCQ_F_FAST_FREE BIT(10)
|
2020-01-19 15:53:46 +00:00
|
|
|
|
|
|
|
/* Queue / Completion Queue */
|
|
|
|
struct ionic_qcq {
|
|
|
|
struct ionic_queue q; /**< Queue */
|
|
|
|
struct ionic_cq cq; /**< Completion Queue */
|
|
|
|
struct ionic_lif *lif; /**< LIF */
|
|
|
|
const struct rte_memzone *base_z;
|
|
|
|
void *base;
|
|
|
|
rte_iova_t base_pa;
|
2021-02-16 20:35:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ionic_admin_qcq {
|
|
|
|
struct ionic_qcq qcq;
|
|
|
|
uint16_t flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ionic_notify_qcq {
|
|
|
|
struct ionic_qcq qcq;
|
|
|
|
uint16_t flags;
|
|
|
|
|
2020-01-19 15:53:46 +00:00
|
|
|
struct ionic_intr_info intr;
|
|
|
|
};
|
|
|
|
|
2021-02-16 20:35:33 +00:00
|
|
|
struct ionic_rx_qcq {
|
|
|
|
/* cacheline0, cacheline1 */
|
|
|
|
struct ionic_qcq qcq;
|
|
|
|
|
|
|
|
/* cacheline2 */
|
|
|
|
struct rte_mempool *mb_pool;
|
2022-10-18 19:41:15 +00:00
|
|
|
uint64_t rearm_data;
|
|
|
|
uint64_t rearm_seg_data;
|
2022-10-18 19:41:31 +00:00
|
|
|
uint64_t last_wdog_cycles;
|
|
|
|
uint64_t wdog_ms;
|
2022-10-18 19:41:04 +00:00
|
|
|
uint16_t frame_size; /* Based on configured MTU */
|
2022-10-18 19:41:12 +00:00
|
|
|
uint16_t hdr_seg_size; /* Length of first segment of RX chain */
|
|
|
|
uint16_t seg_size; /* Length of all subsequent segments */
|
2021-02-16 20:35:33 +00:00
|
|
|
uint16_t flags;
|
2022-10-18 19:41:18 +00:00
|
|
|
uint16_t mb_idx;
|
2021-02-16 20:35:33 +00:00
|
|
|
|
|
|
|
/* cacheline3 (inside stats) */
|
|
|
|
struct ionic_rx_stats stats;
|
2022-10-18 19:41:18 +00:00
|
|
|
|
|
|
|
/* cacheline4+ */
|
|
|
|
struct rte_mbuf *mbs[IONIC_MBUF_BULK_ALLOC] __rte_cache_aligned;
|
2021-02-16 20:35:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ionic_tx_qcq {
|
|
|
|
/* cacheline0, cacheline1 */
|
|
|
|
struct ionic_qcq qcq;
|
|
|
|
|
|
|
|
/* cacheline2 */
|
2022-10-18 19:41:31 +00:00
|
|
|
uint64_t last_wdog_cycles;
|
2021-02-16 20:35:39 +00:00
|
|
|
uint16_t num_segs_fw; /* # segs supported by current FW */
|
2022-10-18 19:41:27 +00:00
|
|
|
uint16_t free_thresh;
|
2021-02-16 20:35:33 +00:00
|
|
|
uint16_t flags;
|
|
|
|
|
|
|
|
struct ionic_tx_stats stats;
|
|
|
|
};
|
|
|
|
|
2021-02-16 20:35:26 +00:00
|
|
|
#define IONIC_Q_TO_QCQ(_q) container_of(_q, struct ionic_qcq, q)
|
|
|
|
#define IONIC_CQ_TO_QCQ(_cq) container_of(_cq, struct ionic_qcq, cq)
|
2020-01-19 15:53:51 +00:00
|
|
|
|
2021-01-18 20:35:00 +00:00
|
|
|
struct ionic_qtype_info {
|
|
|
|
uint8_t version;
|
|
|
|
uint8_t supported;
|
|
|
|
uint64_t features;
|
|
|
|
uint16_t desc_sz;
|
|
|
|
uint16_t comp_sz;
|
|
|
|
uint16_t sg_desc_sz;
|
|
|
|
uint16_t max_sg_elems;
|
|
|
|
uint16_t sg_desc_stride;
|
|
|
|
};
|
|
|
|
|
2020-01-19 15:53:44 +00:00
|
|
|
#define IONIC_LIF_F_INITED BIT(0)
|
2020-01-19 15:53:47 +00:00
|
|
|
#define IONIC_LIF_F_LINK_CHECK_NEEDED BIT(1)
|
2020-12-16 21:12:55 +00:00
|
|
|
#define IONIC_LIF_F_UP BIT(2)
|
|
|
|
#define IONIC_LIF_F_FW_RESET BIT(3)
|
2022-10-18 19:41:24 +00:00
|
|
|
#define IONIC_LIF_F_Q_IN_CMB BIT(4)
|
2020-01-19 15:53:44 +00:00
|
|
|
|
|
|
|
#define IONIC_LIF_NAME_MAX_SZ (32)
|
|
|
|
|
|
|
|
struct ionic_lif {
|
|
|
|
struct ionic_adapter *adapter;
|
|
|
|
struct rte_eth_dev *eth_dev;
|
|
|
|
uint16_t port_id; /**< Device port identifier */
|
2022-10-18 19:41:04 +00:00
|
|
|
uint16_t frame_size;
|
2020-01-19 15:53:44 +00:00
|
|
|
uint32_t hw_index;
|
|
|
|
uint32_t state;
|
2020-01-19 15:53:51 +00:00
|
|
|
uint32_t ntxqcqs;
|
|
|
|
uint32_t nrxqcqs;
|
2020-01-19 15:53:46 +00:00
|
|
|
rte_spinlock_t adminq_lock;
|
|
|
|
rte_spinlock_t adminq_service_lock;
|
2021-02-16 20:35:33 +00:00
|
|
|
struct ionic_admin_qcq *adminqcq;
|
|
|
|
struct ionic_notify_qcq *notifyqcq;
|
|
|
|
struct ionic_tx_qcq **txqcqs;
|
|
|
|
struct ionic_rx_qcq **rxqcqs;
|
2020-01-19 15:53:49 +00:00
|
|
|
struct ionic_rx_filters rx_filters;
|
2020-01-19 15:53:45 +00:00
|
|
|
struct ionic_doorbell __iomem *kern_dbpage;
|
2020-01-19 15:53:47 +00:00
|
|
|
uint64_t last_eid;
|
2020-01-19 15:53:48 +00:00
|
|
|
uint64_t features;
|
|
|
|
uint32_t hw_features;
|
|
|
|
uint32_t rx_mode;
|
2020-01-19 15:53:44 +00:00
|
|
|
char name[IONIC_LIF_NAME_MAX_SZ];
|
2020-01-19 15:53:48 +00:00
|
|
|
uint8_t mac_addr[RTE_ETHER_ADDR_LEN];
|
2020-01-19 15:53:52 +00:00
|
|
|
uint16_t rss_types;
|
|
|
|
uint8_t rss_hash_key[IONIC_RSS_HASH_KEY_SIZE];
|
|
|
|
uint8_t *rss_ind_tbl;
|
|
|
|
rte_iova_t rss_ind_tbl_pa;
|
|
|
|
const struct rte_memzone *rss_ind_tbl_z;
|
2020-12-16 21:12:51 +00:00
|
|
|
uint32_t rss_ind_tbl_nrxqcqs;
|
2020-01-19 15:53:44 +00:00
|
|
|
uint32_t info_sz;
|
|
|
|
struct ionic_lif_info *info;
|
|
|
|
rte_iova_t info_pa;
|
|
|
|
const struct rte_memzone *info_z;
|
2021-01-18 20:35:00 +00:00
|
|
|
|
|
|
|
struct ionic_qtype_info qtype_info[IONIC_QTYPE_MAX];
|
|
|
|
uint8_t qtype_ver[IONIC_QTYPE_MAX];
|
|
|
|
|
2020-01-19 15:53:53 +00:00
|
|
|
struct rte_eth_stats stats_base;
|
|
|
|
struct ionic_lif_stats lif_stats_base;
|
2020-01-19 15:53:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int ionic_lif_identify(struct ionic_adapter *adapter);
|
|
|
|
int ionic_lifs_size(struct ionic_adapter *ionic);
|
|
|
|
|
|
|
|
int ionic_lif_alloc(struct ionic_lif *lif);
|
|
|
|
void ionic_lif_free(struct ionic_lif *lif);
|
2020-12-16 21:12:54 +00:00
|
|
|
void ionic_lif_free_queues(struct ionic_lif *lif);
|
2020-01-19 15:53:44 +00:00
|
|
|
|
|
|
|
int ionic_lif_init(struct ionic_lif *lif);
|
|
|
|
void ionic_lif_deinit(struct ionic_lif *lif);
|
|
|
|
|
|
|
|
int ionic_lif_start(struct ionic_lif *lif);
|
2020-12-16 21:12:55 +00:00
|
|
|
void ionic_lif_stop(struct ionic_lif *lif);
|
2020-01-19 15:53:44 +00:00
|
|
|
|
2021-01-11 19:02:04 +00:00
|
|
|
void ionic_lif_configure(struct ionic_lif *lif);
|
|
|
|
void ionic_lif_configure_vlan_offload(struct ionic_lif *lif, int mask);
|
2022-10-18 19:41:28 +00:00
|
|
|
void ionic_lif_configure_rx_sg_offload(struct ionic_lif *lif);
|
2020-01-19 15:53:44 +00:00
|
|
|
void ionic_lif_reset(struct ionic_lif *lif);
|
|
|
|
|
2020-01-19 15:53:46 +00:00
|
|
|
int ionic_intr_alloc(struct ionic_lif *lif, struct ionic_intr_info *intr);
|
|
|
|
|
|
|
|
int ionic_qcq_service(struct ionic_qcq *qcq, int budget, ionic_cq_cb cb,
|
|
|
|
void *cb_arg);
|
|
|
|
|
2022-10-18 19:41:04 +00:00
|
|
|
int ionic_lif_change_mtu(struct ionic_lif *lif, uint32_t new_mtu);
|
2020-01-19 15:53:48 +00:00
|
|
|
|
2020-01-19 15:53:49 +00:00
|
|
|
int ionic_dev_add_mac(struct rte_eth_dev *eth_dev,
|
|
|
|
struct rte_ether_addr *mac_addr,
|
|
|
|
uint32_t index __rte_unused, uint32_t pool __rte_unused);
|
|
|
|
void ionic_dev_remove_mac(struct rte_eth_dev *eth_dev,
|
|
|
|
uint32_t index __rte_unused);
|
|
|
|
int ionic_dev_set_mac(struct rte_eth_dev *eth_dev,
|
|
|
|
struct rte_ether_addr *mac_addr);
|
|
|
|
int ionic_dev_vlan_filter_set(struct rte_eth_dev *eth_dev, uint16_t vlan_id,
|
|
|
|
int on);
|
|
|
|
int ionic_dev_promiscuous_enable(struct rte_eth_dev *dev);
|
|
|
|
int ionic_dev_promiscuous_disable(struct rte_eth_dev *dev);
|
|
|
|
int ionic_dev_allmulticast_enable(struct rte_eth_dev *dev);
|
|
|
|
int ionic_dev_allmulticast_disable(struct rte_eth_dev *dev);
|
|
|
|
|
2021-02-16 20:35:34 +00:00
|
|
|
int ionic_rx_qcq_alloc(struct ionic_lif *lif, uint32_t socket_id,
|
2022-10-18 19:41:12 +00:00
|
|
|
uint32_t index, uint16_t nrxq_descs, struct rte_mempool *mp,
|
2021-02-16 20:35:34 +00:00
|
|
|
struct ionic_rx_qcq **qcq_out);
|
|
|
|
int ionic_tx_qcq_alloc(struct ionic_lif *lif, uint32_t socket_id,
|
|
|
|
uint32_t index, uint16_t ntxq_descs,
|
|
|
|
struct ionic_tx_qcq **qcq_out);
|
2020-01-19 15:53:46 +00:00
|
|
|
void ionic_qcq_free(struct ionic_qcq *qcq);
|
|
|
|
|
2021-02-16 20:35:33 +00:00
|
|
|
int ionic_lif_rxq_init(struct ionic_rx_qcq *rxq);
|
|
|
|
void ionic_lif_rxq_deinit(struct ionic_rx_qcq *rxq);
|
2020-01-19 15:53:51 +00:00
|
|
|
|
2021-02-16 20:35:33 +00:00
|
|
|
int ionic_lif_txq_init(struct ionic_tx_qcq *txq);
|
|
|
|
void ionic_lif_txq_deinit(struct ionic_tx_qcq *txq);
|
2020-01-19 15:53:51 +00:00
|
|
|
|
2020-01-19 15:53:52 +00:00
|
|
|
int ionic_lif_rss_config(struct ionic_lif *lif, const uint16_t types,
|
|
|
|
const uint8_t *key, const uint32_t *indir);
|
|
|
|
|
2020-01-19 15:53:48 +00:00
|
|
|
int ionic_lif_set_features(struct ionic_lif *lif);
|
|
|
|
|
2020-01-19 15:53:53 +00:00
|
|
|
void ionic_lif_get_stats(const struct ionic_lif *lif,
|
|
|
|
struct rte_eth_stats *stats);
|
|
|
|
void ionic_lif_reset_stats(struct ionic_lif *lif);
|
|
|
|
|
|
|
|
void ionic_lif_get_hw_stats(struct ionic_lif *lif,
|
|
|
|
struct ionic_lif_stats *stats);
|
|
|
|
void ionic_lif_reset_hw_stats(struct ionic_lif *lif);
|
|
|
|
|
2020-01-19 15:53:47 +00:00
|
|
|
int ionic_notifyq_handler(struct ionic_lif *lif, int budget);
|
|
|
|
|
2020-01-19 15:53:44 +00:00
|
|
|
#endif /* _IONIC_LIF_H_ */
|