1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Huawei HiNIC PCI Express Linux driver
4 * Copyright(c) 2017 Huawei Technologies Co., Ltd
10 #include <linux/netdevice.h>
11 #include <linux/types.h>
12 #include <linux/semaphore.h>
13 #include <linux/workqueue.h>
14 #include <linux/bitops.h>
16 #include "hinic_hw_dev.h"
19 #include "hinic_sriov.h"
21 #define HINIC_DRV_NAME "hinic"
25 #define HINIC_MAX_JUMBO_FRAME_SIZE 15872
26 #define HINIC_MAX_MTU_SIZE (HINIC_MAX_JUMBO_FRAME_SIZE - ETH_HLEN - ETH_FCS_LEN)
27 #define HINIC_MIN_MTU_SIZE 256
30 HINIC_LINK_UP = BIT(0),
31 HINIC_INTF_UP = BIT(1),
32 HINIC_RSS_ENABLE = BIT(2),
33 HINIC_LINK_DOWN = BIT(3),
34 HINIC_LP_TEST = BIT(4),
37 struct hinic_rx_mode_work {
38 struct work_struct work;
42 struct hinic_rss_type {
53 enum hinic_rss_hash_type {
54 HINIC_RSS_HASH_ENGINE_TYPE_XOR,
55 HINIC_RSS_HASH_ENGINE_TYPE_TOEP,
56 HINIC_RSS_HASH_ENGINE_TYPE_MAX,
59 struct hinic_intr_coal_info {
61 u8 coalesce_timer_cfg;
71 struct hinic_debug_priv {
72 struct hinic_dev *dev;
74 enum hinic_dbg_type type;
80 struct net_device *netdev;
81 struct hinic_hwdev *hwdev;
84 unsigned int tx_weight;
85 unsigned int rx_weight;
91 struct semaphore mgmt_lock;
92 unsigned long *vlan_bitmap;
94 struct hinic_rx_mode_work rx_mode_work;
95 struct workqueue_struct *workq;
97 struct hinic_txq *txqs;
98 struct hinic_rxq *rxqs;
106 struct hinic_rss_type rss_type;
109 struct hinic_intr_coal_info *rx_intr_coalesce;
110 struct hinic_intr_coal_info *tx_intr_coalesce;
111 struct hinic_sriov_info sriov_info;
116 struct dentry *dbgfs_root;
117 struct dentry *sq_dbgfs;
118 struct dentry *rq_dbgfs;
119 struct dentry *func_tbl_dbgfs;
120 struct hinic_debug_priv *dbg;
121 struct devlink *devlink;
122 bool cable_unplugged;
123 bool module_unrecognized;
126 struct hinic_devlink_priv {
127 struct hinic_hwdev *hwdev;
128 struct devlink_health_reporter *hw_fault_reporter;
129 struct devlink_health_reporter *fw_fault_reporter;