mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-26 23:15:24 +07:00
Merge branch 'thunderx-next'
Aleksey Makarov says: ==================== net: thunderx: fix problems reported by static check tools These are fixes for the problems that were reported by static check tools. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
41d3b5efe9
@ -11,6 +11,7 @@
|
||||
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/pci.h>
|
||||
#include "thunder_bgx.h"
|
||||
|
||||
/* PCI device IDs */
|
||||
@ -300,7 +301,7 @@ struct nic_cfg_msg {
|
||||
u8 vf_id;
|
||||
u8 tns_mode;
|
||||
u8 node_id;
|
||||
u64 mac_addr;
|
||||
u8 mac_addr[ETH_ALEN];
|
||||
};
|
||||
|
||||
/* Qset configuration */
|
||||
@ -330,7 +331,7 @@ struct sq_cfg_msg {
|
||||
struct set_mac_msg {
|
||||
u8 msg;
|
||||
u8 vf_id;
|
||||
u64 addr;
|
||||
u8 mac_addr[ETH_ALEN];
|
||||
};
|
||||
|
||||
/* Set Maximum frame size */
|
||||
@ -398,15 +399,22 @@ union nic_mbx {
|
||||
struct bgx_link_status link_status;
|
||||
};
|
||||
|
||||
#define NIC_NODE_ID_MASK 0x03
|
||||
#define NIC_NODE_ID_SHIFT 44
|
||||
|
||||
static inline int nic_get_node_id(struct pci_dev *pdev)
|
||||
{
|
||||
u64 addr = pci_resource_start(pdev, PCI_CFG_REG_BAR_NUM);
|
||||
return ((addr >> NIC_NODE_ID_SHIFT) & NIC_NODE_ID_MASK);
|
||||
}
|
||||
|
||||
int nicvf_set_real_num_queues(struct net_device *netdev,
|
||||
int tx_queues, int rx_queues);
|
||||
int nicvf_open(struct net_device *netdev);
|
||||
int nicvf_stop(struct net_device *netdev);
|
||||
int nicvf_send_msg_to_pf(struct nicvf *vf, union nic_mbx *mbx);
|
||||
void nicvf_config_cpi(struct nicvf *nic);
|
||||
void nicvf_config_rss(struct nicvf *nic);
|
||||
void nicvf_set_rss_key(struct nicvf *nic);
|
||||
void nicvf_free_skb(struct nicvf *nic, struct sk_buff *skb);
|
||||
void nicvf_set_ethtool_ops(struct net_device *netdev);
|
||||
void nicvf_update_stats(struct nicvf *nic);
|
||||
void nicvf_update_lmac_stats(struct nicvf *nic);
|
||||
|
@ -23,8 +23,6 @@
|
||||
struct nicpf {
|
||||
struct pci_dev *pdev;
|
||||
u8 rev_id;
|
||||
#define NIC_NODE_ID_MASK 0x300000000000
|
||||
#define NIC_NODE_ID(x) ((x & NODE_ID_MASK) >> 44)
|
||||
u8 node;
|
||||
unsigned int flags;
|
||||
u8 num_vf_en; /* No of VF enabled */
|
||||
@ -494,7 +492,6 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf)
|
||||
u64 *mbx_data;
|
||||
u64 mbx_addr;
|
||||
u64 reg_addr;
|
||||
u64 mac_addr;
|
||||
int bgx, lmac;
|
||||
int i;
|
||||
int ret = 0;
|
||||
@ -557,12 +554,7 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf)
|
||||
lmac = mbx.mac.vf_id;
|
||||
bgx = NIC_GET_BGX_FROM_VF_LMAC_MAP(nic->vf_lmac_map[lmac]);
|
||||
lmac = NIC_GET_LMAC_FROM_VF_LMAC_MAP(nic->vf_lmac_map[lmac]);
|
||||
#ifdef __BIG_ENDIAN
|
||||
mac_addr = cpu_to_be64(mbx.nic_cfg.mac_addr) << 16;
|
||||
#else
|
||||
mac_addr = cpu_to_be64(mbx.nic_cfg.mac_addr) >> 16;
|
||||
#endif
|
||||
bgx_set_lmac_mac(nic->node, bgx, lmac, (u8 *)&mac_addr);
|
||||
bgx_set_lmac_mac(nic->node, bgx, lmac, mbx.mac.mac_addr);
|
||||
break;
|
||||
case NIC_MBOX_MSG_SET_MAX_FRS:
|
||||
ret = nic_update_hw_frs(nic, mbx.frs.max_frs,
|
||||
@ -851,7 +843,7 @@ static int nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
|
||||
pci_read_config_byte(pdev, PCI_REVISION_ID, &nic->rev_id);
|
||||
|
||||
nic->node = NIC_NODE_ID(pci_resource_start(pdev, PCI_CFG_REG_BAR_NUM));
|
||||
nic->node = nic_get_node_id(pdev);
|
||||
|
||||
nic_set_lmac_vf_mapping(nic);
|
||||
|
||||
|
@ -504,8 +504,7 @@ static int nicvf_set_rxfh(struct net_device *dev, const u32 *indir,
|
||||
}
|
||||
|
||||
/* We do not allow change in unsupported parameters */
|
||||
if (hkey ||
|
||||
(hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP))
|
||||
if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
rss->enable = true;
|
||||
|
@ -50,10 +50,6 @@ module_param(cpi_alg, int, S_IRUGO);
|
||||
MODULE_PARM_DESC(cpi_alg,
|
||||
"PFC algorithm (0=none, 1=VLAN, 2=VLAN16, 3=IP Diffserv)");
|
||||
|
||||
static int nicvf_enable_msix(struct nicvf *nic);
|
||||
static netdev_tx_t nicvf_xmit(struct sk_buff *skb, struct net_device *netdev);
|
||||
static void nicvf_read_bgx_stats(struct nicvf *nic, struct bgx_stats_msg *bgx);
|
||||
|
||||
static inline void nicvf_set_rx_frame_cnt(struct nicvf *nic,
|
||||
struct sk_buff *skb)
|
||||
{
|
||||
@ -110,17 +106,23 @@ u64 nicvf_queue_reg_read(struct nicvf *nic, u64 offset, u64 qidx)
|
||||
|
||||
/* VF -> PF mailbox communication */
|
||||
|
||||
static void nicvf_write_to_mbx(struct nicvf *nic, union nic_mbx *mbx)
|
||||
{
|
||||
u64 *msg = (u64 *)mbx;
|
||||
|
||||
nicvf_reg_write(nic, NIC_VF_PF_MAILBOX_0_1 + 0, msg[0]);
|
||||
nicvf_reg_write(nic, NIC_VF_PF_MAILBOX_0_1 + 8, msg[1]);
|
||||
}
|
||||
|
||||
int nicvf_send_msg_to_pf(struct nicvf *nic, union nic_mbx *mbx)
|
||||
{
|
||||
int timeout = NIC_MBOX_MSG_TIMEOUT;
|
||||
int sleep = 10;
|
||||
u64 *msg = (u64 *)mbx;
|
||||
|
||||
nic->pf_acked = false;
|
||||
nic->pf_nacked = false;
|
||||
|
||||
nicvf_reg_write(nic, NIC_VF_PF_MAILBOX_0_1 + 0, msg[0]);
|
||||
nicvf_reg_write(nic, NIC_VF_PF_MAILBOX_0_1 + 8, msg[1]);
|
||||
nicvf_write_to_mbx(nic, mbx);
|
||||
|
||||
/* Wait for previous message to be acked, timeout 2sec */
|
||||
while (!nic->pf_acked) {
|
||||
@ -146,12 +148,13 @@ int nicvf_send_msg_to_pf(struct nicvf *nic, union nic_mbx *mbx)
|
||||
static int nicvf_check_pf_ready(struct nicvf *nic)
|
||||
{
|
||||
int timeout = 5000, sleep = 20;
|
||||
union nic_mbx mbx = {};
|
||||
|
||||
mbx.msg.msg = NIC_MBOX_MSG_READY;
|
||||
|
||||
nic->pf_ready_to_rcv_msg = false;
|
||||
|
||||
nicvf_reg_write(nic, NIC_VF_PF_MAILBOX_0_1 + 0,
|
||||
le64_to_cpu(NIC_MBOX_MSG_READY));
|
||||
nicvf_reg_write(nic, NIC_VF_PF_MAILBOX_0_1 + 8, 1ULL);
|
||||
nicvf_write_to_mbx(nic, &mbx);
|
||||
|
||||
while (!nic->pf_ready_to_rcv_msg) {
|
||||
msleep(sleep);
|
||||
@ -167,6 +170,14 @@ static int nicvf_check_pf_ready(struct nicvf *nic)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void nicvf_read_bgx_stats(struct nicvf *nic, struct bgx_stats_msg *bgx)
|
||||
{
|
||||
if (bgx->rx)
|
||||
nic->bgx_stats.rx_stats[bgx->idx] = bgx->stats;
|
||||
else
|
||||
nic->bgx_stats.tx_stats[bgx->idx] = bgx->stats;
|
||||
}
|
||||
|
||||
static void nicvf_handle_mbx_intr(struct nicvf *nic)
|
||||
{
|
||||
union nic_mbx mbx = {};
|
||||
@ -190,8 +201,7 @@ static void nicvf_handle_mbx_intr(struct nicvf *nic)
|
||||
nic->vf_id = mbx.nic_cfg.vf_id & 0x7F;
|
||||
nic->tns_mode = mbx.nic_cfg.tns_mode & 0x7F;
|
||||
nic->node = mbx.nic_cfg.node_id;
|
||||
ether_addr_copy(nic->netdev->dev_addr,
|
||||
(u8 *)&mbx.nic_cfg.mac_addr);
|
||||
ether_addr_copy(nic->netdev->dev_addr, mbx.nic_cfg.mac_addr);
|
||||
nic->link_up = false;
|
||||
nic->duplex = 0;
|
||||
nic->speed = 0;
|
||||
@ -241,18 +251,15 @@ static void nicvf_handle_mbx_intr(struct nicvf *nic)
|
||||
static int nicvf_hw_set_mac_addr(struct nicvf *nic, struct net_device *netdev)
|
||||
{
|
||||
union nic_mbx mbx = {};
|
||||
int i;
|
||||
|
||||
mbx.mac.msg = NIC_MBOX_MSG_SET_MAC;
|
||||
mbx.mac.vf_id = nic->vf_id;
|
||||
for (i = 0; i < ETH_ALEN; i++)
|
||||
mbx.mac.addr = (mbx.mac.addr << 8) |
|
||||
netdev->dev_addr[i];
|
||||
ether_addr_copy(mbx.mac.mac_addr, netdev->dev_addr);
|
||||
|
||||
return nicvf_send_msg_to_pf(nic, &mbx);
|
||||
}
|
||||
|
||||
void nicvf_config_cpi(struct nicvf *nic)
|
||||
static void nicvf_config_cpi(struct nicvf *nic)
|
||||
{
|
||||
union nic_mbx mbx = {};
|
||||
|
||||
@ -264,7 +271,7 @@ void nicvf_config_cpi(struct nicvf *nic)
|
||||
nicvf_send_msg_to_pf(nic, &mbx);
|
||||
}
|
||||
|
||||
void nicvf_get_rss_size(struct nicvf *nic)
|
||||
static void nicvf_get_rss_size(struct nicvf *nic)
|
||||
{
|
||||
union nic_mbx mbx = {};
|
||||
|
||||
@ -326,11 +333,11 @@ static int nicvf_rss_init(struct nicvf *nic)
|
||||
rss->enable = true;
|
||||
|
||||
/* Using the HW reset value for now */
|
||||
rss->key[0] = 0xFEED0BADFEED0BAD;
|
||||
rss->key[1] = 0xFEED0BADFEED0BAD;
|
||||
rss->key[2] = 0xFEED0BADFEED0BAD;
|
||||
rss->key[3] = 0xFEED0BADFEED0BAD;
|
||||
rss->key[4] = 0xFEED0BADFEED0BAD;
|
||||
rss->key[0] = 0xFEED0BADFEED0BADULL;
|
||||
rss->key[1] = 0xFEED0BADFEED0BADULL;
|
||||
rss->key[2] = 0xFEED0BADFEED0BADULL;
|
||||
rss->key[3] = 0xFEED0BADFEED0BADULL;
|
||||
rss->key[4] = 0xFEED0BADFEED0BADULL;
|
||||
|
||||
nicvf_set_rss_key(nic);
|
||||
|
||||
@ -368,7 +375,9 @@ int nicvf_set_real_num_queues(struct net_device *netdev,
|
||||
static int nicvf_init_resources(struct nicvf *nic)
|
||||
{
|
||||
int err;
|
||||
u64 mbx_addr = NIC_VF_PF_MAILBOX_0_1;
|
||||
union nic_mbx mbx = {};
|
||||
|
||||
mbx.msg.msg = NIC_MBOX_MSG_CFG_DONE;
|
||||
|
||||
/* Enable Qset */
|
||||
nicvf_qset_config(nic, true);
|
||||
@ -382,9 +391,7 @@ static int nicvf_init_resources(struct nicvf *nic)
|
||||
}
|
||||
|
||||
/* Send VF config done msg to PF */
|
||||
nicvf_reg_write(nic, mbx_addr, le64_to_cpu(NIC_MBOX_MSG_CFG_DONE));
|
||||
mbx_addr += (NIC_PF_VF_MAILBOX_SIZE - 1) * 8;
|
||||
nicvf_reg_write(nic, mbx_addr, 1ULL);
|
||||
nicvf_write_to_mbx(nic, &mbx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -572,7 +579,7 @@ static int nicvf_poll(struct napi_struct *napi, int budget)
|
||||
*
|
||||
* As of now only CQ errors are handled
|
||||
*/
|
||||
void nicvf_handle_qs_err(unsigned long data)
|
||||
static void nicvf_handle_qs_err(unsigned long data)
|
||||
{
|
||||
struct nicvf *nic = (struct nicvf *)data;
|
||||
struct queue_set *qs = nic->qs;
|
||||
@ -1040,14 +1047,6 @@ static int nicvf_set_mac_address(struct net_device *netdev, void *p)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void nicvf_read_bgx_stats(struct nicvf *nic, struct bgx_stats_msg *bgx)
|
||||
{
|
||||
if (bgx->rx)
|
||||
nic->bgx_stats.rx_stats[bgx->idx] = bgx->stats;
|
||||
else
|
||||
nic->bgx_stats.tx_stats[bgx->idx] = bgx->stats;
|
||||
}
|
||||
|
||||
void nicvf_update_lmac_stats(struct nicvf *nic)
|
||||
{
|
||||
int stat = 0;
|
||||
@ -1138,7 +1137,7 @@ void nicvf_update_stats(struct nicvf *nic)
|
||||
nicvf_update_sq_stats(nic, qidx);
|
||||
}
|
||||
|
||||
struct rtnl_link_stats64 *nicvf_get_stats64(struct net_device *netdev,
|
||||
static struct rtnl_link_stats64 *nicvf_get_stats64(struct net_device *netdev,
|
||||
struct rtnl_link_stats64 *stats)
|
||||
{
|
||||
struct nicvf *nic = netdev_priv(netdev);
|
||||
|
@ -62,8 +62,7 @@ static int nicvf_alloc_q_desc_mem(struct nicvf *nic, struct q_desc_mem *dmem,
|
||||
|
||||
/* Align memory address for 'align_bytes' */
|
||||
dmem->phys_base = NICVF_ALIGNED_ADDR((u64)dmem->dma, align_bytes);
|
||||
dmem->base = (void *)((u8 *)dmem->unalign_base +
|
||||
(dmem->phys_base - dmem->dma));
|
||||
dmem->base = dmem->unalign_base + (dmem->phys_base - dmem->dma);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -228,7 +227,7 @@ static void nicvf_free_rbdr(struct nicvf *nic, struct rbdr *rbdr)
|
||||
|
||||
/* Refill receive buffer descriptors with new buffers.
|
||||
*/
|
||||
void nicvf_refill_rbdr(struct nicvf *nic, gfp_t gfp)
|
||||
static void nicvf_refill_rbdr(struct nicvf *nic, gfp_t gfp)
|
||||
{
|
||||
struct queue_set *qs = nic->qs;
|
||||
int rbdr_idx = qs->rbdr_cnt;
|
||||
@ -357,7 +356,9 @@ static int nicvf_init_snd_queue(struct nicvf *nic,
|
||||
return err;
|
||||
|
||||
sq->desc = sq->dmem.base;
|
||||
sq->skbuff = kcalloc(q_len, sizeof(u64), GFP_ATOMIC);
|
||||
sq->skbuff = kcalloc(q_len, sizeof(u64), GFP_KERNEL);
|
||||
if (!sq->skbuff)
|
||||
return -ENOMEM;
|
||||
sq->head = 0;
|
||||
sq->tail = 0;
|
||||
atomic_set(&sq->free_cnt, q_len - 1);
|
||||
|
@ -38,7 +38,7 @@ struct lmac {
|
||||
bool is_sgmii;
|
||||
struct delayed_work dwork;
|
||||
struct workqueue_struct *check_link;
|
||||
} lmac;
|
||||
};
|
||||
|
||||
struct bgx {
|
||||
u8 bgx_id;
|
||||
@ -50,9 +50,9 @@ struct bgx {
|
||||
int use_training;
|
||||
void __iomem *reg_base;
|
||||
struct pci_dev *pdev;
|
||||
} bgx;
|
||||
};
|
||||
|
||||
struct bgx *bgx_vnic[MAX_BGX_THUNDER];
|
||||
static struct bgx *bgx_vnic[MAX_BGX_THUNDER];
|
||||
static int lmac_count; /* Total no of LMACs in system */
|
||||
|
||||
static int bgx_xaui_check_link(struct lmac *lmac);
|
||||
@ -163,7 +163,7 @@ void bgx_get_lmac_link_state(int node, int bgx_idx, int lmacid, void *status)
|
||||
}
|
||||
EXPORT_SYMBOL(bgx_get_lmac_link_state);
|
||||
|
||||
const char *bgx_get_lmac_mac(int node, int bgx_idx, int lmacid)
|
||||
const u8 *bgx_get_lmac_mac(int node, int bgx_idx, int lmacid)
|
||||
{
|
||||
struct bgx *bgx = bgx_vnic[(node * MAX_BGX_PER_CN88XX) + bgx_idx];
|
||||
|
||||
@ -174,7 +174,7 @@ const char *bgx_get_lmac_mac(int node, int bgx_idx, int lmacid)
|
||||
}
|
||||
EXPORT_SYMBOL(bgx_get_lmac_mac);
|
||||
|
||||
void bgx_set_lmac_mac(int node, int bgx_idx, int lmacid, const char *mac)
|
||||
void bgx_set_lmac_mac(int node, int bgx_idx, int lmacid, const u8 *mac)
|
||||
{
|
||||
struct bgx *bgx = bgx_vnic[(node * MAX_BGX_PER_CN88XX) + bgx_idx];
|
||||
|
||||
@ -253,7 +253,7 @@ static void bgx_sgmii_change_link_state(struct lmac *lmac)
|
||||
bgx_reg_write(bgx, lmac->lmacid, BGX_CMRX_CFG, cmr_cfg);
|
||||
}
|
||||
|
||||
void bgx_lmac_handler(struct net_device *netdev)
|
||||
static void bgx_lmac_handler(struct net_device *netdev)
|
||||
{
|
||||
struct lmac *lmac = container_of(netdev, struct lmac, netdev);
|
||||
struct phy_device *phydev = lmac->phydev;
|
||||
@ -655,7 +655,7 @@ static int bgx_lmac_enable(struct bgx *bgx, u8 lmacid)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bgx_lmac_disable(struct bgx *bgx, u8 lmacid)
|
||||
static void bgx_lmac_disable(struct bgx *bgx, u8 lmacid)
|
||||
{
|
||||
struct lmac *lmac;
|
||||
u64 cmrx_cfg;
|
||||
@ -894,8 +894,8 @@ static int bgx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||
goto err_release_regions;
|
||||
}
|
||||
bgx->bgx_id = (pci_resource_start(pdev, PCI_CFG_REG_BAR_NUM) >> 24) & 1;
|
||||
bgx->bgx_id += NODE_ID(pci_resource_start(pdev, PCI_CFG_REG_BAR_NUM))
|
||||
* MAX_BGX_PER_CN88XX;
|
||||
bgx->bgx_id += nic_get_node_id(pdev) * MAX_BGX_PER_CN88XX;
|
||||
|
||||
bgx_vnic[bgx->bgx_id] = bgx;
|
||||
bgx_get_qlm_mode(bgx);
|
||||
|
||||
|
@ -20,9 +20,6 @@
|
||||
|
||||
#define MAX_LMAC (MAX_BGX_PER_CN88XX * MAX_LMAC_PER_BGX)
|
||||
|
||||
#define NODE_ID_MASK 0x300000000000
|
||||
#define NODE_ID(x) ((x & NODE_ID_MASK) >> 44)
|
||||
|
||||
/* Registers */
|
||||
#define BGX_CMRX_CFG 0x00
|
||||
#define CMR_PKT_TX_EN BIT_ULL(13)
|
||||
@ -186,8 +183,8 @@ enum MCAST_MODE {
|
||||
void bgx_add_dmac_addr(u64 dmac, int node, int bgx_idx, int lmac);
|
||||
unsigned bgx_get_map(int node);
|
||||
int bgx_get_lmac_count(int node, int bgx);
|
||||
const char *bgx_get_lmac_mac(int node, int bgx_idx, int lmacid);
|
||||
void bgx_set_lmac_mac(int node, int bgx_idx, int lmacid, const char *mac);
|
||||
const u8 *bgx_get_lmac_mac(int node, int bgx_idx, int lmacid);
|
||||
void bgx_set_lmac_mac(int node, int bgx_idx, int lmacid, const u8 *mac);
|
||||
void bgx_get_lmac_link_state(int node, int bgx_idx, int lmacid, void *status);
|
||||
u64 bgx_get_rx_stats(int node, int bgx_idx, int lmac, int idx);
|
||||
u64 bgx_get_tx_stats(int node, int bgx_idx, int lmac, int idx);
|
||||
|
Loading…
Reference in New Issue
Block a user