Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 41d3b5ef authored by David S. Miller's avatar David S. Miller
Browse files

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: default avatarDavid S. Miller <davem@davemloft.net>
parents dda922c8 86ace693
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -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);
+2 −10
Original line number Diff line number Diff line
@@ -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);

+1 −2
Original line number Diff line number Diff line
@@ -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;
+36 −37
Original line number Diff line number Diff line
@@ -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);
+5 −4
Original line number Diff line number Diff line
@@ -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);
Loading