2023-06-26 11:44:57 -07:00
|
|
|
// SPDX-License-Identifier: BSD-2-Clause-Views
|
2019-07-17 18:13:51 -07:00
|
|
|
/*
|
2023-06-26 11:44:57 -07:00
|
|
|
* Copyright (c) 2019-2023 The Regents of the University of California
|
2021-10-21 14:55:48 -07:00
|
|
|
*/
|
2019-07-17 18:13:51 -07:00
|
|
|
|
|
|
|
#ifndef MQNIC_H
|
|
|
|
#define MQNIC_H
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
2021-10-12 19:32:25 +02:00
|
|
|
#ifdef CONFIG_PCI
|
2019-07-17 18:13:51 -07:00
|
|
|
#include <linux/pci.h>
|
2021-10-12 19:32:25 +02:00
|
|
|
#endif
|
2022-04-21 13:18:00 -07:00
|
|
|
#ifdef CONFIG_AUXILIARY_BUS
|
|
|
|
#include <linux/auxiliary_bus.h>
|
|
|
|
#endif
|
2021-10-12 19:32:25 +02:00
|
|
|
#include <linux/platform_device.h>
|
2019-07-17 18:13:51 -07:00
|
|
|
#include <linux/miscdevice.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
#include <linux/net_tstamp.h>
|
|
|
|
#include <linux/ptp_clock_kernel.h>
|
2022-05-13 19:13:41 +02:00
|
|
|
#include <linux/timer.h>
|
2023-09-13 16:40:27 -07:00
|
|
|
#include <net/devlink.h>
|
2019-07-17 18:13:51 -07:00
|
|
|
|
|
|
|
#include <linux/i2c.h>
|
|
|
|
#include <linux/i2c-algo-bit.h>
|
|
|
|
|
|
|
|
#define DRIVER_NAME "mqnic"
|
|
|
|
#define DRIVER_VERSION "0.1"
|
|
|
|
|
|
|
|
#include "mqnic_hw.h"
|
|
|
|
|
2022-04-24 22:54:04 -07:00
|
|
|
#ifdef CONFIG_OF
|
|
|
|
/* platform driver OF-related definitions */
|
|
|
|
#define MQNIC_PROP_MAC_ADDR_INC_BYTE "mac-address-increment-byte"
|
|
|
|
#define MQNIC_PROP_MAC_ADDR_INC "mac-address-increment"
|
|
|
|
#define MQNIC_PROP_MAC_ADDR_LOCAL "mac-address-local"
|
|
|
|
#define MQNIC_PROP_MODULE_EEPROM "module-eeproms"
|
|
|
|
#endif
|
|
|
|
|
2022-05-13 19:13:41 +02:00
|
|
|
// default interval to poll port TX/RX status, in ms
|
|
|
|
#define MQNIC_LINK_STATUS_POLL_MS 1000
|
|
|
|
|
2023-04-30 21:48:34 -07:00
|
|
|
extern unsigned int mqnic_num_eq_entries;
|
|
|
|
extern unsigned int mqnic_num_txq_entries;
|
|
|
|
extern unsigned int mqnic_num_rxq_entries;
|
2021-10-21 10:43:06 +02:00
|
|
|
|
2022-05-13 19:13:41 +02:00
|
|
|
extern unsigned int mqnic_link_status_poll;
|
|
|
|
|
2021-02-01 20:10:48 -08:00
|
|
|
struct mqnic_dev;
|
2021-12-12 17:28:43 -08:00
|
|
|
struct mqnic_if;
|
2021-02-01 20:10:48 -08:00
|
|
|
|
2023-05-01 22:04:43 -07:00
|
|
|
struct mqnic_res {
|
|
|
|
unsigned int count;
|
|
|
|
u8 __iomem *base;
|
|
|
|
unsigned int stride;
|
2023-05-02 21:23:30 -07:00
|
|
|
|
|
|
|
spinlock_t lock;
|
|
|
|
unsigned long *bmap;
|
2023-05-01 22:04:43 -07:00
|
|
|
};
|
|
|
|
|
2022-04-24 23:01:15 -07:00
|
|
|
struct mqnic_reg_block {
|
2022-03-26 00:18:07 -07:00
|
|
|
u32 type;
|
|
|
|
u32 version;
|
|
|
|
u8 __iomem *regs;
|
|
|
|
u8 __iomem *base;
|
2021-12-29 22:31:46 -08:00
|
|
|
};
|
|
|
|
|
2021-02-01 20:10:48 -08:00
|
|
|
struct mqnic_board_ops {
|
2021-10-08 18:31:53 -07:00
|
|
|
int (*init)(struct mqnic_dev *mqnic);
|
|
|
|
void (*deinit)(struct mqnic_dev *mqnic);
|
2021-02-01 20:10:48 -08:00
|
|
|
};
|
|
|
|
|
2021-10-08 18:31:53 -07:00
|
|
|
struct mqnic_i2c_bus {
|
|
|
|
struct mqnic_dev *mqnic;
|
2019-07-17 18:13:51 -07:00
|
|
|
|
2021-10-08 18:31:53 -07:00
|
|
|
u8 __iomem *scl_in_reg;
|
|
|
|
u8 __iomem *scl_out_reg;
|
|
|
|
u8 __iomem *sda_in_reg;
|
|
|
|
u8 __iomem *sda_out_reg;
|
2019-07-17 18:13:51 -07:00
|
|
|
|
2021-10-21 22:19:01 -07:00
|
|
|
u32 scl_in_mask;
|
|
|
|
u32 scl_out_mask;
|
|
|
|
u32 sda_in_mask;
|
|
|
|
u32 sda_out_mask;
|
2021-02-01 20:10:48 -08:00
|
|
|
|
2021-10-08 18:31:53 -07:00
|
|
|
struct list_head head;
|
2021-02-01 20:10:48 -08:00
|
|
|
|
2021-10-08 18:31:53 -07:00
|
|
|
struct i2c_algo_bit_data algo;
|
|
|
|
struct i2c_adapter adapter;
|
2019-07-17 18:13:51 -07:00
|
|
|
};
|
|
|
|
|
2021-12-12 13:34:33 -08:00
|
|
|
struct mqnic_irq {
|
|
|
|
int index;
|
|
|
|
int irqn;
|
2021-10-12 19:32:25 +02:00
|
|
|
char name[16 + 3];
|
2021-12-12 13:34:33 -08:00
|
|
|
struct atomic_notifier_head nh;
|
|
|
|
};
|
|
|
|
|
2022-04-21 13:18:00 -07:00
|
|
|
#ifdef CONFIG_AUXILIARY_BUS
|
|
|
|
struct mqnic_adev {
|
|
|
|
struct auxiliary_device adev;
|
|
|
|
struct mqnic_dev *mdev;
|
|
|
|
struct mqnic_adev **ptr;
|
|
|
|
char name[32];
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2019-07-17 18:13:51 -07:00
|
|
|
struct mqnic_dev {
|
2021-10-08 18:31:53 -07:00
|
|
|
struct device *dev;
|
2021-10-12 19:32:25 +02:00
|
|
|
#ifdef CONFIG_PCI
|
2021-10-08 18:31:53 -07:00
|
|
|
struct pci_dev *pdev;
|
2021-10-12 19:32:25 +02:00
|
|
|
#endif
|
|
|
|
struct platform_device *pfdev;
|
2019-07-17 18:13:51 -07:00
|
|
|
|
2021-10-08 18:31:53 -07:00
|
|
|
resource_size_t hw_regs_size;
|
|
|
|
phys_addr_t hw_regs_phys;
|
|
|
|
u8 __iomem *hw_addr;
|
|
|
|
u8 __iomem *phc_hw_addr;
|
2019-07-17 18:13:51 -07:00
|
|
|
|
2021-10-08 18:31:53 -07:00
|
|
|
resource_size_t app_hw_regs_size;
|
|
|
|
phys_addr_t app_hw_regs_phys;
|
|
|
|
u8 __iomem *app_hw_addr;
|
2021-09-09 17:50:44 -07:00
|
|
|
|
2021-10-08 18:31:53 -07:00
|
|
|
resource_size_t ram_hw_regs_size;
|
|
|
|
phys_addr_t ram_hw_regs_phys;
|
|
|
|
u8 __iomem *ram_hw_addr;
|
2021-09-09 17:50:44 -07:00
|
|
|
|
2021-10-08 18:31:53 -07:00
|
|
|
struct mutex state_lock;
|
2019-11-18 16:17:27 -08:00
|
|
|
|
2021-10-08 18:31:53 -07:00
|
|
|
int mac_count;
|
|
|
|
u8 mac_list[MQNIC_MAX_IF][ETH_ALEN];
|
2019-07-17 18:13:51 -07:00
|
|
|
|
2021-10-08 18:31:53 -07:00
|
|
|
char name[16];
|
2019-07-17 18:13:51 -07:00
|
|
|
|
2021-10-08 18:31:53 -07:00
|
|
|
int irq_count;
|
2021-12-12 13:34:33 -08:00
|
|
|
struct mqnic_irq *irq[MQNIC_MAX_IRQ];
|
2019-09-13 13:53:36 -07:00
|
|
|
|
2021-10-08 18:31:53 -07:00
|
|
|
unsigned int id;
|
|
|
|
struct list_head dev_list_node;
|
2019-07-17 18:13:51 -07:00
|
|
|
|
2021-10-08 18:31:53 -07:00
|
|
|
struct miscdevice misc_dev;
|
2019-07-17 18:13:51 -07:00
|
|
|
|
2022-04-21 13:18:00 -07:00
|
|
|
#ifdef CONFIG_AUXILIARY_BUS
|
|
|
|
struct mqnic_adev *app_adev;
|
|
|
|
#endif
|
|
|
|
|
2022-04-24 23:01:15 -07:00
|
|
|
struct mqnic_reg_block *rb_list;
|
|
|
|
struct mqnic_reg_block *fw_id_rb;
|
|
|
|
struct mqnic_reg_block *if_rb;
|
2022-11-23 17:49:38 -08:00
|
|
|
struct mqnic_reg_block *stats_rb;
|
2022-11-23 17:49:14 -08:00
|
|
|
struct mqnic_reg_block *clk_info_rb;
|
2022-04-24 23:01:15 -07:00
|
|
|
struct mqnic_reg_block *phc_rb;
|
2021-12-29 22:31:46 -08:00
|
|
|
|
2023-09-13 16:40:27 -07:00
|
|
|
int phys_port_max;
|
2021-12-29 14:29:55 -08:00
|
|
|
|
2021-12-29 22:31:46 -08:00
|
|
|
u32 fpga_id;
|
2021-10-08 18:31:53 -07:00
|
|
|
u32 fw_id;
|
|
|
|
u32 fw_ver;
|
|
|
|
u32 board_id;
|
|
|
|
u32 board_ver;
|
2021-12-29 22:31:46 -08:00
|
|
|
u32 build_date;
|
|
|
|
u32 git_hash;
|
|
|
|
u32 rel_info;
|
2019-07-17 18:13:51 -07:00
|
|
|
|
2022-04-21 13:15:45 -07:00
|
|
|
u32 app_id;
|
|
|
|
|
2022-11-23 17:49:38 -08:00
|
|
|
u32 stats_offset;
|
|
|
|
u32 stats_count;
|
|
|
|
u32 stats_stride;
|
|
|
|
u32 stats_flags;
|
|
|
|
|
2022-11-23 17:49:14 -08:00
|
|
|
u32 core_clk_nom_per_ns_num;
|
|
|
|
u32 core_clk_nom_per_ns_denom;
|
|
|
|
u32 core_clk_nom_freq_hz;
|
|
|
|
u32 ref_clk_nom_per_ns_num;
|
|
|
|
u32 ref_clk_nom_per_ns_denom;
|
|
|
|
u32 ref_clk_nom_freq_hz;
|
|
|
|
u32 clk_info_channels;
|
|
|
|
|
2021-12-29 22:31:46 -08:00
|
|
|
u32 if_offset;
|
2021-10-08 18:31:53 -07:00
|
|
|
u32 if_count;
|
|
|
|
u32 if_stride;
|
|
|
|
u32 if_csr_offset;
|
2019-07-17 18:13:51 -07:00
|
|
|
|
2023-09-12 11:16:10 -07:00
|
|
|
char build_date_str[32];
|
|
|
|
|
2021-12-12 17:28:43 -08:00
|
|
|
struct mqnic_if *interface[MQNIC_MAX_IF];
|
2019-07-17 18:13:51 -07:00
|
|
|
|
2021-10-08 18:31:53 -07:00
|
|
|
struct ptp_clock *ptp_clock;
|
|
|
|
struct ptp_clock_info ptp_clock_info;
|
2019-07-17 18:13:51 -07:00
|
|
|
|
2021-10-08 18:31:53 -07:00
|
|
|
struct mqnic_board_ops *board_ops;
|
2021-02-01 20:10:48 -08:00
|
|
|
|
2021-10-08 18:31:53 -07:00
|
|
|
struct list_head i2c_bus;
|
|
|
|
int i2c_adapter_count;
|
2019-07-17 18:13:51 -07:00
|
|
|
|
2021-10-08 18:31:53 -07:00
|
|
|
int mod_i2c_client_count;
|
|
|
|
struct i2c_client *mod_i2c_client[MQNIC_MAX_IF];
|
|
|
|
struct i2c_client *eeprom_i2c_client;
|
2019-07-17 18:13:51 -07:00
|
|
|
};
|
|
|
|
|
2020-04-21 17:18:58 -07:00
|
|
|
struct mqnic_frag {
|
2021-10-08 18:31:53 -07:00
|
|
|
dma_addr_t dma_addr;
|
|
|
|
u32 len;
|
2020-04-21 17:18:58 -07:00
|
|
|
};
|
|
|
|
|
2019-07-17 18:13:51 -07:00
|
|
|
struct mqnic_tx_info {
|
2021-10-08 18:31:53 -07:00
|
|
|
struct sk_buff *skb;
|
|
|
|
DEFINE_DMA_UNMAP_ADDR(dma_addr);
|
|
|
|
DEFINE_DMA_UNMAP_LEN(len);
|
|
|
|
u32 frag_count;
|
|
|
|
struct mqnic_frag frags[MQNIC_MAX_FRAGS - 1];
|
|
|
|
int ts_requested;
|
2019-07-17 18:13:51 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mqnic_rx_info {
|
2021-10-08 18:31:53 -07:00
|
|
|
struct page *page;
|
|
|
|
u32 page_order;
|
|
|
|
u32 page_offset;
|
|
|
|
dma_addr_t dma_addr;
|
|
|
|
u32 len;
|
2019-07-17 18:13:51 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mqnic_ring {
|
2021-10-08 18:31:53 -07:00
|
|
|
// written on enqueue (i.e. start_xmit)
|
2023-07-07 01:19:19 -07:00
|
|
|
u32 prod_ptr;
|
2021-10-08 18:31:53 -07:00
|
|
|
u64 bytes;
|
|
|
|
u64 packets;
|
|
|
|
u64 dropped_packets;
|
|
|
|
struct netdev_queue *tx_queue;
|
|
|
|
|
|
|
|
// written from completion
|
2023-07-07 01:19:19 -07:00
|
|
|
u32 cons_ptr ____cacheline_aligned_in_smp;
|
2021-10-08 18:31:53 -07:00
|
|
|
u64 ts_s;
|
|
|
|
u8 ts_valid;
|
|
|
|
|
|
|
|
// mostly constant
|
|
|
|
u32 size;
|
|
|
|
u32 full_size;
|
|
|
|
u32 size_mask;
|
|
|
|
u32 stride;
|
|
|
|
|
|
|
|
u32 cpl_index;
|
|
|
|
|
|
|
|
u32 mtu;
|
|
|
|
u32 page_order;
|
|
|
|
|
|
|
|
u32 desc_block_size;
|
|
|
|
u32 log_desc_block_size;
|
|
|
|
|
|
|
|
size_t buf_size;
|
|
|
|
u8 *buf;
|
|
|
|
dma_addr_t buf_dma_addr;
|
|
|
|
|
|
|
|
union {
|
|
|
|
struct mqnic_tx_info *tx_info;
|
|
|
|
struct mqnic_rx_info *rx_info;
|
|
|
|
};
|
|
|
|
|
2021-12-10 20:59:44 -08:00
|
|
|
struct device *dev;
|
2021-12-12 17:28:43 -08:00
|
|
|
struct mqnic_if *interface;
|
2021-12-10 20:59:44 -08:00
|
|
|
struct mqnic_priv *priv;
|
2021-12-12 13:46:09 -08:00
|
|
|
int index;
|
2023-04-30 21:48:34 -07:00
|
|
|
struct mqnic_cq *cq;
|
2023-05-02 21:23:30 -07:00
|
|
|
int enabled;
|
2021-12-10 20:59:44 -08:00
|
|
|
|
2021-10-08 18:31:53 -07:00
|
|
|
u8 __iomem *hw_addr;
|
2019-07-17 18:13:51 -07:00
|
|
|
} ____cacheline_aligned_in_smp;
|
|
|
|
|
2023-04-30 21:48:34 -07:00
|
|
|
struct mqnic_cq {
|
2023-07-07 01:19:19 -07:00
|
|
|
u32 prod_ptr;
|
2019-07-17 18:13:51 -07:00
|
|
|
|
2023-07-07 01:19:19 -07:00
|
|
|
u32 cons_ptr;
|
2019-07-17 18:13:51 -07:00
|
|
|
|
2021-10-08 18:31:53 -07:00
|
|
|
u32 size;
|
|
|
|
u32 size_mask;
|
|
|
|
u32 stride;
|
2019-07-17 18:13:51 -07:00
|
|
|
|
2021-10-08 18:31:53 -07:00
|
|
|
size_t buf_size;
|
|
|
|
u8 *buf;
|
|
|
|
dma_addr_t buf_dma_addr;
|
2019-07-17 18:13:51 -07:00
|
|
|
|
2021-12-12 01:53:38 -08:00
|
|
|
struct device *dev;
|
2021-12-12 17:28:43 -08:00
|
|
|
struct mqnic_if *interface;
|
2021-10-08 18:31:53 -07:00
|
|
|
struct napi_struct napi;
|
2023-04-30 21:48:34 -07:00
|
|
|
int cqn;
|
|
|
|
struct mqnic_eq *eq;
|
2021-12-12 14:20:56 -08:00
|
|
|
struct mqnic_ring *src_ring;
|
2023-05-02 21:23:30 -07:00
|
|
|
int enabled;
|
2019-07-17 18:13:51 -07:00
|
|
|
|
2023-04-30 21:48:34 -07:00
|
|
|
void (*handler)(struct mqnic_cq *cq);
|
2019-07-17 18:13:51 -07:00
|
|
|
|
2021-10-08 18:31:53 -07:00
|
|
|
u8 __iomem *hw_addr;
|
2019-07-17 18:13:51 -07:00
|
|
|
};
|
|
|
|
|
2023-04-30 21:48:34 -07:00
|
|
|
struct mqnic_eq {
|
2023-07-07 01:19:19 -07:00
|
|
|
u32 prod_ptr;
|
2019-07-17 18:13:51 -07:00
|
|
|
|
2023-07-07 01:19:19 -07:00
|
|
|
u32 cons_ptr;
|
2019-07-17 18:13:51 -07:00
|
|
|
|
2021-10-08 18:31:53 -07:00
|
|
|
u32 size;
|
|
|
|
u32 size_mask;
|
|
|
|
u32 stride;
|
2019-07-17 18:13:51 -07:00
|
|
|
|
2021-10-08 18:31:53 -07:00
|
|
|
size_t buf_size;
|
|
|
|
u8 *buf;
|
|
|
|
dma_addr_t buf_dma_addr;
|
2019-07-17 18:13:51 -07:00
|
|
|
|
2021-12-12 01:53:38 -08:00
|
|
|
struct device *dev;
|
2021-12-12 17:28:43 -08:00
|
|
|
struct mqnic_if *interface;
|
2023-04-30 21:48:34 -07:00
|
|
|
int eqn;
|
2021-12-12 13:34:33 -08:00
|
|
|
struct mqnic_irq *irq;
|
2023-05-02 21:23:30 -07:00
|
|
|
int enabled;
|
2019-07-17 18:13:51 -07:00
|
|
|
|
2021-12-10 21:05:31 -08:00
|
|
|
struct notifier_block irq_nb;
|
2019-09-13 13:53:36 -07:00
|
|
|
|
2023-04-30 21:48:34 -07:00
|
|
|
void (*handler)(struct mqnic_eq *eq);
|
2019-07-17 18:13:51 -07:00
|
|
|
|
2023-05-02 21:23:30 -07:00
|
|
|
spinlock_t table_lock;
|
|
|
|
struct radix_tree_root cq_table;
|
|
|
|
|
2021-10-08 18:31:53 -07:00
|
|
|
u8 __iomem *hw_addr;
|
2019-07-17 18:13:51 -07:00
|
|
|
};
|
|
|
|
|
2021-12-29 22:31:46 -08:00
|
|
|
struct mqnic_sched {
|
|
|
|
struct device *dev;
|
|
|
|
struct mqnic_if *interface;
|
2022-03-28 17:23:27 -07:00
|
|
|
struct mqnic_sched_block *sched_block;
|
2021-12-29 22:31:46 -08:00
|
|
|
|
2022-04-24 23:01:15 -07:00
|
|
|
struct mqnic_reg_block *rb;
|
2021-12-29 22:31:46 -08:00
|
|
|
|
|
|
|
int index;
|
|
|
|
|
|
|
|
u32 type;
|
|
|
|
u32 offset;
|
|
|
|
u32 channel_count;
|
|
|
|
u32 channel_stride;
|
|
|
|
|
|
|
|
u8 __iomem *hw_addr;
|
|
|
|
};
|
|
|
|
|
2022-05-04 09:03:37 -07:00
|
|
|
struct mqnic_port {
|
|
|
|
struct device *dev;
|
|
|
|
struct mqnic_if *interface;
|
|
|
|
|
|
|
|
struct mqnic_reg_block *port_rb;
|
|
|
|
struct mqnic_reg_block *rb_list;
|
|
|
|
struct mqnic_reg_block *port_ctrl_rb;
|
|
|
|
|
|
|
|
int index;
|
2023-09-13 16:40:27 -07:00
|
|
|
int phys_index;
|
2022-05-04 09:03:37 -07:00
|
|
|
|
|
|
|
u32 port_features;
|
2023-09-13 16:40:27 -07:00
|
|
|
|
|
|
|
struct devlink_port dl_port;
|
2022-05-04 09:03:37 -07:00
|
|
|
};
|
|
|
|
|
2022-03-28 17:23:27 -07:00
|
|
|
struct mqnic_sched_block {
|
2021-10-08 18:31:53 -07:00
|
|
|
struct device *dev;
|
2021-12-12 17:28:43 -08:00
|
|
|
struct mqnic_if *interface;
|
2019-08-19 15:59:57 -07:00
|
|
|
|
2022-04-24 23:01:15 -07:00
|
|
|
struct mqnic_reg_block *block_rb;
|
|
|
|
struct mqnic_reg_block *rb_list;
|
2021-12-29 22:31:46 -08:00
|
|
|
|
2021-10-08 18:31:53 -07:00
|
|
|
int index;
|
2019-08-19 15:59:57 -07:00
|
|
|
|
2021-10-08 18:31:53 -07:00
|
|
|
u32 sched_count;
|
2021-12-29 22:31:46 -08:00
|
|
|
struct mqnic_sched *sched[MQNIC_MAX_PORTS];
|
2019-08-19 15:59:57 -07:00
|
|
|
};
|
|
|
|
|
2021-12-12 17:28:43 -08:00
|
|
|
struct mqnic_if {
|
2021-10-08 18:31:53 -07:00
|
|
|
struct device *dev;
|
|
|
|
struct mqnic_dev *mdev;
|
|
|
|
|
2022-04-24 23:01:15 -07:00
|
|
|
struct mqnic_reg_block *rb_list;
|
|
|
|
struct mqnic_reg_block *if_ctrl_rb;
|
2023-04-30 21:48:34 -07:00
|
|
|
struct mqnic_reg_block *eq_rb;
|
2023-07-10 17:52:34 -07:00
|
|
|
struct mqnic_reg_block *cq_rb;
|
2023-04-30 21:48:34 -07:00
|
|
|
struct mqnic_reg_block *txq_rb;
|
|
|
|
struct mqnic_reg_block *rxq_rb;
|
2022-04-24 23:01:15 -07:00
|
|
|
struct mqnic_reg_block *rx_queue_map_rb;
|
2021-12-29 22:31:46 -08:00
|
|
|
|
2021-12-10 21:01:51 -08:00
|
|
|
int index;
|
2021-10-08 18:31:53 -07:00
|
|
|
|
2022-01-15 21:53:13 -08:00
|
|
|
u32 if_features;
|
2021-12-29 22:31:46 -08:00
|
|
|
|
|
|
|
u32 max_tx_mtu;
|
|
|
|
u32 max_rx_mtu;
|
2023-09-10 23:22:50 -07:00
|
|
|
u32 tx_fifo_depth;
|
|
|
|
u32 rx_fifo_depth;
|
2021-12-12 17:28:43 -08:00
|
|
|
|
2023-05-01 22:04:43 -07:00
|
|
|
struct mqnic_res *eq_res;
|
2023-07-10 17:52:34 -07:00
|
|
|
struct mqnic_res *cq_res;
|
2023-05-01 22:04:43 -07:00
|
|
|
struct mqnic_res *txq_res;
|
|
|
|
struct mqnic_res *rxq_res;
|
|
|
|
|
2023-04-30 21:48:34 -07:00
|
|
|
u32 eq_count;
|
|
|
|
struct mqnic_eq *eq[MQNIC_MAX_EQ];
|
2021-12-12 17:28:43 -08:00
|
|
|
|
2021-10-08 18:31:53 -07:00
|
|
|
u32 port_count;
|
2022-05-04 09:03:37 -07:00
|
|
|
struct mqnic_port *port[MQNIC_MAX_PORTS];
|
2022-03-28 17:23:27 -07:00
|
|
|
|
2022-05-04 09:03:37 -07:00
|
|
|
u32 sched_block_count;
|
2022-03-28 17:23:27 -07:00
|
|
|
struct mqnic_sched_block *sched_block[MQNIC_MAX_PORTS];
|
2021-10-08 18:31:53 -07:00
|
|
|
|
|
|
|
u32 max_desc_block_size;
|
|
|
|
|
2023-04-10 15:05:32 -07:00
|
|
|
u32 rx_queue_map_indir_table_size;
|
|
|
|
u8 __iomem *rx_queue_map_indir_table[MQNIC_MAX_PORTS];
|
|
|
|
|
2021-12-29 22:31:46 -08:00
|
|
|
resource_size_t hw_regs_size;
|
2021-10-08 18:31:53 -07:00
|
|
|
u8 __iomem *hw_addr;
|
|
|
|
u8 __iomem *csr_hw_addr;
|
|
|
|
|
2021-12-12 17:28:43 -08:00
|
|
|
u32 ndev_count;
|
|
|
|
struct net_device *ndev[MQNIC_MAX_PORTS];
|
|
|
|
|
|
|
|
struct i2c_client *mod_i2c_client;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mqnic_priv {
|
|
|
|
struct device *dev;
|
|
|
|
struct net_device *ndev;
|
2023-09-13 16:40:27 -07:00
|
|
|
struct devlink_port *dl_port;
|
2021-12-12 17:28:43 -08:00
|
|
|
struct mqnic_dev *mdev;
|
|
|
|
struct mqnic_if *interface;
|
|
|
|
|
|
|
|
spinlock_t stats_lock;
|
|
|
|
|
|
|
|
int index;
|
|
|
|
bool registered;
|
|
|
|
bool port_up;
|
|
|
|
|
2022-01-15 21:53:13 -08:00
|
|
|
u32 if_features;
|
2021-12-12 17:28:43 -08:00
|
|
|
|
2022-05-13 19:13:41 +02:00
|
|
|
unsigned int link_status;
|
|
|
|
struct timer_list link_status_timer;
|
|
|
|
|
2023-04-30 21:48:34 -07:00
|
|
|
u32 txq_count;
|
|
|
|
u32 rxq_count;
|
2021-12-12 17:28:43 -08:00
|
|
|
|
2023-05-03 01:22:12 -07:00
|
|
|
u32 tx_ring_size;
|
|
|
|
u32 rx_ring_size;
|
|
|
|
|
2023-05-02 21:23:30 -07:00
|
|
|
struct rw_semaphore txq_table_sem;
|
|
|
|
struct radix_tree_root txq_table;
|
|
|
|
|
|
|
|
struct rw_semaphore rxq_table_sem;
|
|
|
|
struct radix_tree_root rxq_table;
|
2021-12-12 17:28:43 -08:00
|
|
|
|
2023-09-13 16:40:27 -07:00
|
|
|
struct mqnic_sched_block *sched_block;
|
|
|
|
struct mqnic_port *port;
|
2023-09-06 21:48:38 -07:00
|
|
|
|
2021-12-12 17:28:43 -08:00
|
|
|
u32 max_desc_block_size;
|
|
|
|
|
2023-05-03 16:50:59 -07:00
|
|
|
u32 rx_queue_map_indir_table_size;
|
|
|
|
u32 *rx_queue_map_indir_table;
|
|
|
|
|
2021-10-08 18:31:53 -07:00
|
|
|
struct hwtstamp_config hwts_config;
|
|
|
|
|
|
|
|
struct i2c_client *mod_i2c_client;
|
2019-07-17 18:13:51 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
// mqnic_main.c
|
|
|
|
|
2023-09-12 11:17:24 -07:00
|
|
|
// mqnic_devlink.c
|
|
|
|
struct devlink *mqnic_devlink_alloc(struct device *dev);
|
|
|
|
void mqnic_devlink_free(struct devlink *devlink);
|
|
|
|
|
2023-05-01 22:04:43 -07:00
|
|
|
// mqnic_res.c
|
|
|
|
struct mqnic_res *mqnic_create_res(unsigned int count, u8 __iomem *base, unsigned int stride);
|
|
|
|
void mqnic_destroy_res(struct mqnic_res *res);
|
2023-05-02 21:23:30 -07:00
|
|
|
int mqnic_res_alloc(struct mqnic_res *res);
|
|
|
|
void mqnic_res_free(struct mqnic_res *res, int index);
|
2023-05-01 22:04:43 -07:00
|
|
|
unsigned int mqnic_res_get_count(struct mqnic_res *res);
|
|
|
|
u8 __iomem *mqnic_res_get_addr(struct mqnic_res *res, int index);
|
|
|
|
|
2021-12-29 22:31:46 -08:00
|
|
|
// mqnic_reg_block.c
|
2022-04-24 23:01:15 -07:00
|
|
|
struct mqnic_reg_block *mqnic_enumerate_reg_block_list(u8 __iomem *base, size_t offset, size_t size);
|
|
|
|
struct mqnic_reg_block *mqnic_find_reg_block(struct mqnic_reg_block *list, u32 type, u32 version, int index);
|
|
|
|
void mqnic_free_reg_block_list(struct mqnic_reg_block *list);
|
2021-12-29 22:31:46 -08:00
|
|
|
|
2021-12-12 13:34:33 -08:00
|
|
|
// mqnic_irq.c
|
|
|
|
int mqnic_irq_init_pcie(struct mqnic_dev *mdev);
|
|
|
|
void mqnic_irq_deinit_pcie(struct mqnic_dev *mdev);
|
2021-10-12 19:32:25 +02:00
|
|
|
int mqnic_irq_init_platform(struct mqnic_dev *mdev);
|
2021-12-12 13:34:33 -08:00
|
|
|
|
2019-07-17 18:13:51 -07:00
|
|
|
// mqnic_dev.c
|
|
|
|
extern const struct file_operations mqnic_fops;
|
|
|
|
|
2021-12-12 17:28:43 -08:00
|
|
|
// mqnic_if.c
|
2023-04-30 21:57:32 -07:00
|
|
|
struct mqnic_if *mqnic_create_interface(struct mqnic_dev *mdev, int index, u8 __iomem *hw_addr);
|
|
|
|
void mqnic_destroy_interface(struct mqnic_if *interface);
|
2021-12-29 22:31:46 -08:00
|
|
|
u32 mqnic_interface_get_tx_mtu(struct mqnic_if *interface);
|
|
|
|
void mqnic_interface_set_tx_mtu(struct mqnic_if *interface, u32 mtu);
|
|
|
|
u32 mqnic_interface_get_rx_mtu(struct mqnic_if *interface);
|
|
|
|
void mqnic_interface_set_rx_mtu(struct mqnic_if *interface, u32 mtu);
|
2022-04-23 00:12:22 -07:00
|
|
|
u32 mqnic_interface_get_rx_queue_map_rss_mask(struct mqnic_if *interface, int port);
|
|
|
|
void mqnic_interface_set_rx_queue_map_rss_mask(struct mqnic_if *interface, int port, u32 val);
|
|
|
|
u32 mqnic_interface_get_rx_queue_map_app_mask(struct mqnic_if *interface, int port);
|
|
|
|
void mqnic_interface_set_rx_queue_map_app_mask(struct mqnic_if *interface, int port, u32 val);
|
2023-04-10 15:05:32 -07:00
|
|
|
u32 mqnic_interface_get_rx_queue_map_indir_table(struct mqnic_if *interface, int port, int index);
|
|
|
|
void mqnic_interface_set_rx_queue_map_indir_table(struct mqnic_if *interface, int port, int index, u32 val);
|
2021-12-12 17:28:43 -08:00
|
|
|
|
2022-05-04 09:03:37 -07:00
|
|
|
// mqnic_port.c
|
2023-04-30 21:57:32 -07:00
|
|
|
struct mqnic_port *mqnic_create_port(struct mqnic_if *interface, int index,
|
2023-09-13 16:40:27 -07:00
|
|
|
int phys_index, struct mqnic_reg_block *port_rb);
|
2023-04-30 21:57:32 -07:00
|
|
|
void mqnic_destroy_port(struct mqnic_port *port);
|
2023-09-09 19:01:36 -07:00
|
|
|
u32 mqnic_port_get_tx_ctrl(struct mqnic_port *port);
|
|
|
|
void mqnic_port_set_tx_ctrl(struct mqnic_port *port, u32 val);
|
|
|
|
u32 mqnic_port_get_rx_ctrl(struct mqnic_port *port);
|
|
|
|
void mqnic_port_set_rx_ctrl(struct mqnic_port *port, u32 val);
|
|
|
|
u32 mqnic_port_get_fc_ctrl(struct mqnic_port *port);
|
|
|
|
void mqnic_port_set_fc_ctrl(struct mqnic_port *port, u32 val);
|
|
|
|
u32 mqnic_port_get_lfc_ctrl(struct mqnic_port *port);
|
|
|
|
void mqnic_port_set_lfc_ctrl(struct mqnic_port *port, u32 val);
|
|
|
|
u32 mqnic_port_get_pfc_ctrl(struct mqnic_port *port, int index);
|
|
|
|
void mqnic_port_set_pfc_ctrl(struct mqnic_port *port, int index, u32 val);
|
2022-05-04 09:03:37 -07:00
|
|
|
|
2019-07-17 18:13:51 -07:00
|
|
|
// mqnic_netdev.c
|
2023-05-03 01:20:07 -07:00
|
|
|
int mqnic_start_port(struct net_device *ndev);
|
|
|
|
void mqnic_stop_port(struct net_device *ndev);
|
2023-05-03 16:50:59 -07:00
|
|
|
int mqnic_update_indir_table(struct net_device *ndev);
|
2019-07-17 18:13:51 -07:00
|
|
|
void mqnic_update_stats(struct net_device *ndev);
|
2023-09-13 16:40:27 -07:00
|
|
|
struct net_device *mqnic_create_netdev(struct mqnic_if *interface, int index,
|
|
|
|
struct mqnic_port *port, struct mqnic_sched_block *sched_block);
|
2023-04-30 21:57:32 -07:00
|
|
|
void mqnic_destroy_netdev(struct net_device *ndev);
|
2019-07-17 18:13:51 -07:00
|
|
|
|
2022-03-28 17:23:27 -07:00
|
|
|
// mqnic_sched_block.c
|
2023-04-30 21:57:32 -07:00
|
|
|
struct mqnic_sched_block *mqnic_create_sched_block(struct mqnic_if *interface,
|
2022-04-24 23:01:15 -07:00
|
|
|
int index, struct mqnic_reg_block *rb);
|
2023-04-30 21:57:32 -07:00
|
|
|
void mqnic_destroy_sched_block(struct mqnic_sched_block *block);
|
2022-03-28 17:23:27 -07:00
|
|
|
int mqnic_activate_sched_block(struct mqnic_sched_block *block);
|
|
|
|
void mqnic_deactivate_sched_block(struct mqnic_sched_block *block);
|
2021-12-29 22:31:46 -08:00
|
|
|
|
|
|
|
// mqnic_scheduler.c
|
2023-04-30 21:57:32 -07:00
|
|
|
struct mqnic_sched *mqnic_create_scheduler(struct mqnic_sched_block *block,
|
2022-04-24 23:01:15 -07:00
|
|
|
int index, struct mqnic_reg_block *rb);
|
2023-04-30 21:57:32 -07:00
|
|
|
void mqnic_destroy_scheduler(struct mqnic_sched *sched);
|
2021-12-29 22:31:46 -08:00
|
|
|
int mqnic_scheduler_enable(struct mqnic_sched *sched);
|
|
|
|
void mqnic_scheduler_disable(struct mqnic_sched *sched);
|
2019-08-19 15:59:57 -07:00
|
|
|
|
2019-07-17 18:13:51 -07:00
|
|
|
// mqnic_ptp.c
|
|
|
|
void mqnic_register_phc(struct mqnic_dev *mdev);
|
|
|
|
void mqnic_unregister_phc(struct mqnic_dev *mdev);
|
2021-10-08 18:31:53 -07:00
|
|
|
ktime_t mqnic_read_cpl_ts(struct mqnic_dev *mdev, struct mqnic_ring *ring,
|
2021-10-21 13:54:00 -07:00
|
|
|
const struct mqnic_cpl *cpl);
|
2019-07-17 18:13:51 -07:00
|
|
|
|
2019-08-08 21:31:29 -07:00
|
|
|
// mqnic_i2c.c
|
2021-12-29 22:31:46 -08:00
|
|
|
struct mqnic_i2c_bus *mqnic_i2c_bus_create(struct mqnic_dev *mqnic, int index);
|
|
|
|
struct i2c_adapter *mqnic_i2c_adapter_create(struct mqnic_dev *mqnic, int index);
|
2021-02-01 20:10:48 -08:00
|
|
|
void mqnic_i2c_bus_release(struct mqnic_i2c_bus *bus);
|
|
|
|
void mqnic_i2c_adapter_release(struct i2c_adapter *adapter);
|
|
|
|
int mqnic_i2c_init(struct mqnic_dev *mqnic);
|
|
|
|
void mqnic_i2c_deinit(struct mqnic_dev *mqnic);
|
|
|
|
|
|
|
|
// mqnic_board.c
|
|
|
|
int mqnic_board_init(struct mqnic_dev *mqnic);
|
|
|
|
void mqnic_board_deinit(struct mqnic_dev *mqnic);
|
2019-08-08 21:31:29 -07:00
|
|
|
|
2022-11-23 17:49:14 -08:00
|
|
|
// mqnic_clk_info.c
|
|
|
|
void mqnic_clk_info_init(struct mqnic_dev *mdev);
|
|
|
|
u32 mqnic_get_core_clk_nom_freq_hz(struct mqnic_dev *mdev);
|
|
|
|
u32 mqnic_get_ref_clk_nom_freq_hz(struct mqnic_dev *mdev);
|
|
|
|
u32 mqnic_get_core_clk_freq_hz(struct mqnic_dev *mdev);
|
|
|
|
u32 mqnic_get_clk_freq_hz(struct mqnic_dev *mdev, int ch);
|
2022-11-24 01:41:31 -08:00
|
|
|
u64 mqnic_core_clk_cycles_to_ns(struct mqnic_dev *mdev, u64 cycles);
|
|
|
|
u64 mqnic_core_clk_ns_to_cycles(struct mqnic_dev *mdev, u64 ns);
|
|
|
|
u64 mqnic_ref_clk_cycles_to_ns(struct mqnic_dev *mdev, u64 cycles);
|
|
|
|
u64 mqnic_ref_clk_ns_to_cycles(struct mqnic_dev *mdev, u64 ns);
|
2022-11-23 17:49:14 -08:00
|
|
|
|
2022-11-23 17:49:38 -08:00
|
|
|
// mqnic_stats.c
|
|
|
|
void mqnic_stats_init(struct mqnic_dev *mdev);
|
|
|
|
u64 mqnic_stats_read(struct mqnic_dev *mdev, int index);
|
|
|
|
|
2019-07-17 18:13:51 -07:00
|
|
|
// mqnic_eq.c
|
2023-05-02 21:23:30 -07:00
|
|
|
struct mqnic_eq *mqnic_create_eq(struct mqnic_if *interface);
|
2023-04-30 21:57:32 -07:00
|
|
|
void mqnic_destroy_eq(struct mqnic_eq *eq);
|
2023-05-02 21:23:30 -07:00
|
|
|
int mqnic_open_eq(struct mqnic_eq *eq, struct mqnic_irq *irq, int size);
|
|
|
|
void mqnic_close_eq(struct mqnic_eq *eq);
|
|
|
|
int mqnic_eq_attach_cq(struct mqnic_eq *eq, struct mqnic_cq *cq);
|
|
|
|
void mqnic_eq_detach_cq(struct mqnic_eq *eq, struct mqnic_cq *cq);
|
2023-07-07 01:19:19 -07:00
|
|
|
void mqnic_eq_read_prod_ptr(struct mqnic_eq *eq);
|
|
|
|
void mqnic_eq_write_cons_ptr(struct mqnic_eq *eq);
|
2023-04-30 21:48:34 -07:00
|
|
|
void mqnic_arm_eq(struct mqnic_eq *eq);
|
|
|
|
void mqnic_process_eq(struct mqnic_eq *eq);
|
2019-07-17 18:13:51 -07:00
|
|
|
|
|
|
|
// mqnic_cq.c
|
2023-05-02 21:23:30 -07:00
|
|
|
struct mqnic_cq *mqnic_create_cq(struct mqnic_if *interface);
|
2023-04-30 21:57:32 -07:00
|
|
|
void mqnic_destroy_cq(struct mqnic_cq *cq);
|
2023-07-10 17:52:34 -07:00
|
|
|
int mqnic_open_cq(struct mqnic_cq *cq, struct mqnic_eq *eq, int size);
|
2023-05-02 21:23:30 -07:00
|
|
|
void mqnic_close_cq(struct mqnic_cq *cq);
|
2023-07-07 01:19:19 -07:00
|
|
|
void mqnic_cq_read_prod_ptr(struct mqnic_cq *cq);
|
|
|
|
void mqnic_cq_write_cons_ptr(struct mqnic_cq *cq);
|
2023-04-30 21:48:34 -07:00
|
|
|
void mqnic_arm_cq(struct mqnic_cq *cq);
|
2019-07-17 18:13:51 -07:00
|
|
|
|
|
|
|
// mqnic_tx.c
|
2023-05-02 21:23:30 -07:00
|
|
|
struct mqnic_ring *mqnic_create_tx_ring(struct mqnic_if *interface);
|
2023-04-30 21:57:32 -07:00
|
|
|
void mqnic_destroy_tx_ring(struct mqnic_ring *ring);
|
2023-05-02 21:23:30 -07:00
|
|
|
int mqnic_open_tx_ring(struct mqnic_ring *ring, struct mqnic_priv *priv,
|
|
|
|
struct mqnic_cq *cq, int size, int desc_block_size);
|
|
|
|
void mqnic_close_tx_ring(struct mqnic_ring *ring);
|
|
|
|
int mqnic_enable_tx_ring(struct mqnic_ring *ring);
|
|
|
|
void mqnic_disable_tx_ring(struct mqnic_ring *ring);
|
2019-07-17 18:13:51 -07:00
|
|
|
bool mqnic_is_tx_ring_empty(const struct mqnic_ring *ring);
|
|
|
|
bool mqnic_is_tx_ring_full(const struct mqnic_ring *ring);
|
2023-07-07 01:19:19 -07:00
|
|
|
void mqnic_tx_read_cons_ptr(struct mqnic_ring *ring);
|
|
|
|
void mqnic_tx_write_prod_ptr(struct mqnic_ring *ring);
|
2021-12-10 20:59:44 -08:00
|
|
|
void mqnic_free_tx_desc(struct mqnic_ring *ring, int index, int napi_budget);
|
|
|
|
int mqnic_free_tx_buf(struct mqnic_ring *ring);
|
2023-04-30 21:48:34 -07:00
|
|
|
int mqnic_process_tx_cq(struct mqnic_cq *cq, int napi_budget);
|
|
|
|
void mqnic_tx_irq(struct mqnic_cq *cq);
|
2019-07-17 18:13:51 -07:00
|
|
|
int mqnic_poll_tx_cq(struct napi_struct *napi, int budget);
|
|
|
|
netdev_tx_t mqnic_start_xmit(struct sk_buff *skb, struct net_device *dev);
|
|
|
|
|
|
|
|
// mqnic_rx.c
|
2023-05-02 21:23:30 -07:00
|
|
|
struct mqnic_ring *mqnic_create_rx_ring(struct mqnic_if *interface);
|
2023-04-30 21:57:32 -07:00
|
|
|
void mqnic_destroy_rx_ring(struct mqnic_ring *ring);
|
2023-05-02 21:23:30 -07:00
|
|
|
int mqnic_open_rx_ring(struct mqnic_ring *ring, struct mqnic_priv *priv,
|
|
|
|
struct mqnic_cq *cq, int size, int desc_block_size);
|
|
|
|
void mqnic_close_rx_ring(struct mqnic_ring *ring);
|
|
|
|
int mqnic_enable_rx_ring(struct mqnic_ring *ring);
|
|
|
|
void mqnic_disable_rx_ring(struct mqnic_ring *ring);
|
2019-07-17 18:13:51 -07:00
|
|
|
bool mqnic_is_rx_ring_empty(const struct mqnic_ring *ring);
|
|
|
|
bool mqnic_is_rx_ring_full(const struct mqnic_ring *ring);
|
2023-07-07 01:19:19 -07:00
|
|
|
void mqnic_rx_read_cons_ptr(struct mqnic_ring *ring);
|
|
|
|
void mqnic_rx_write_prod_ptr(struct mqnic_ring *ring);
|
2021-12-10 20:59:44 -08:00
|
|
|
void mqnic_free_rx_desc(struct mqnic_ring *ring, int index);
|
|
|
|
int mqnic_free_rx_buf(struct mqnic_ring *ring);
|
|
|
|
int mqnic_prepare_rx_desc(struct mqnic_ring *ring, int index);
|
2022-06-29 11:56:22 +02:00
|
|
|
int mqnic_refill_rx_buffers(struct mqnic_ring *ring);
|
2023-04-30 21:48:34 -07:00
|
|
|
int mqnic_process_rx_cq(struct mqnic_cq *cq, int napi_budget);
|
|
|
|
void mqnic_rx_irq(struct mqnic_cq *cq);
|
2019-07-17 18:13:51 -07:00
|
|
|
int mqnic_poll_rx_cq(struct napi_struct *napi, int budget);
|
|
|
|
|
|
|
|
// mqnic_ethtool.c
|
|
|
|
extern const struct ethtool_ops mqnic_ethtool_ops;
|
|
|
|
|
|
|
|
#endif /* MQNIC_H */
|