Skip to content

Commit 41d3b5e

Browse files
committed
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 <[email protected]>
2 parents dda922c + 86ace69 commit 41d3b5e

File tree

7 files changed

+67
-71
lines changed

7 files changed

+67
-71
lines changed

drivers/net/ethernet/cavium/thunder/nic.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include <linux/netdevice.h>
1313
#include <linux/interrupt.h>
14+
#include <linux/pci.h>
1415
#include "thunder_bgx.h"
1516

1617
/* PCI device IDs */
@@ -300,7 +301,7 @@ struct nic_cfg_msg {
300301
u8 vf_id;
301302
u8 tns_mode;
302303
u8 node_id;
303-
u64 mac_addr;
304+
u8 mac_addr[ETH_ALEN];
304305
};
305306

306307
/* Qset configuration */
@@ -330,7 +331,7 @@ struct sq_cfg_msg {
330331
struct set_mac_msg {
331332
u8 msg;
332333
u8 vf_id;
333-
u64 addr;
334+
u8 mac_addr[ETH_ALEN];
334335
};
335336

336337
/* Set Maximum frame size */
@@ -398,15 +399,22 @@ union nic_mbx {
398399
struct bgx_link_status link_status;
399400
};
400401

402+
#define NIC_NODE_ID_MASK 0x03
403+
#define NIC_NODE_ID_SHIFT 44
404+
405+
static inline int nic_get_node_id(struct pci_dev *pdev)
406+
{
407+
u64 addr = pci_resource_start(pdev, PCI_CFG_REG_BAR_NUM);
408+
return ((addr >> NIC_NODE_ID_SHIFT) & NIC_NODE_ID_MASK);
409+
}
410+
401411
int nicvf_set_real_num_queues(struct net_device *netdev,
402412
int tx_queues, int rx_queues);
403413
int nicvf_open(struct net_device *netdev);
404414
int nicvf_stop(struct net_device *netdev);
405415
int nicvf_send_msg_to_pf(struct nicvf *vf, union nic_mbx *mbx);
406-
void nicvf_config_cpi(struct nicvf *nic);
407416
void nicvf_config_rss(struct nicvf *nic);
408417
void nicvf_set_rss_key(struct nicvf *nic);
409-
void nicvf_free_skb(struct nicvf *nic, struct sk_buff *skb);
410418
void nicvf_set_ethtool_ops(struct net_device *netdev);
411419
void nicvf_update_stats(struct nicvf *nic);
412420
void nicvf_update_lmac_stats(struct nicvf *nic);

drivers/net/ethernet/cavium/thunder/nic_main.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
struct nicpf {
2424
struct pci_dev *pdev;
2525
u8 rev_id;
26-
#define NIC_NODE_ID_MASK 0x300000000000
27-
#define NIC_NODE_ID(x) ((x & NODE_ID_MASK) >> 44)
2826
u8 node;
2927
unsigned int flags;
3028
u8 num_vf_en; /* No of VF enabled */
@@ -494,7 +492,6 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf)
494492
u64 *mbx_data;
495493
u64 mbx_addr;
496494
u64 reg_addr;
497-
u64 mac_addr;
498495
int bgx, lmac;
499496
int i;
500497
int ret = 0;
@@ -557,12 +554,7 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf)
557554
lmac = mbx.mac.vf_id;
558555
bgx = NIC_GET_BGX_FROM_VF_LMAC_MAP(nic->vf_lmac_map[lmac]);
559556
lmac = NIC_GET_LMAC_FROM_VF_LMAC_MAP(nic->vf_lmac_map[lmac]);
560-
#ifdef __BIG_ENDIAN
561-
mac_addr = cpu_to_be64(mbx.nic_cfg.mac_addr) << 16;
562-
#else
563-
mac_addr = cpu_to_be64(mbx.nic_cfg.mac_addr) >> 16;
564-
#endif
565-
bgx_set_lmac_mac(nic->node, bgx, lmac, (u8 *)&mac_addr);
557+
bgx_set_lmac_mac(nic->node, bgx, lmac, mbx.mac.mac_addr);
566558
break;
567559
case NIC_MBOX_MSG_SET_MAX_FRS:
568560
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)
851843

852844
pci_read_config_byte(pdev, PCI_REVISION_ID, &nic->rev_id);
853845

854-
nic->node = NIC_NODE_ID(pci_resource_start(pdev, PCI_CFG_REG_BAR_NUM));
846+
nic->node = nic_get_node_id(pdev);
855847

856848
nic_set_lmac_vf_mapping(nic);
857849

drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,7 @@ static int nicvf_set_rxfh(struct net_device *dev, const u32 *indir,
504504
}
505505

506506
/* We do not allow change in unsupported parameters */
507-
if (hkey ||
508-
(hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP))
507+
if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP)
509508
return -EOPNOTSUPP;
510509

511510
rss->enable = true;

drivers/net/ethernet/cavium/thunder/nicvf_main.c

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ module_param(cpi_alg, int, S_IRUGO);
5050
MODULE_PARM_DESC(cpi_alg,
5151
"PFC algorithm (0=none, 1=VLAN, 2=VLAN16, 3=IP Diffserv)");
5252

53-
static int nicvf_enable_msix(struct nicvf *nic);
54-
static netdev_tx_t nicvf_xmit(struct sk_buff *skb, struct net_device *netdev);
55-
static void nicvf_read_bgx_stats(struct nicvf *nic, struct bgx_stats_msg *bgx);
56-
5753
static inline void nicvf_set_rx_frame_cnt(struct nicvf *nic,
5854
struct sk_buff *skb)
5955
{
@@ -110,17 +106,23 @@ u64 nicvf_queue_reg_read(struct nicvf *nic, u64 offset, u64 qidx)
110106

111107
/* VF -> PF mailbox communication */
112108

109+
static void nicvf_write_to_mbx(struct nicvf *nic, union nic_mbx *mbx)
110+
{
111+
u64 *msg = (u64 *)mbx;
112+
113+
nicvf_reg_write(nic, NIC_VF_PF_MAILBOX_0_1 + 0, msg[0]);
114+
nicvf_reg_write(nic, NIC_VF_PF_MAILBOX_0_1 + 8, msg[1]);
115+
}
116+
113117
int nicvf_send_msg_to_pf(struct nicvf *nic, union nic_mbx *mbx)
114118
{
115119
int timeout = NIC_MBOX_MSG_TIMEOUT;
116120
int sleep = 10;
117-
u64 *msg = (u64 *)mbx;
118121

119122
nic->pf_acked = false;
120123
nic->pf_nacked = false;
121124

122-
nicvf_reg_write(nic, NIC_VF_PF_MAILBOX_0_1 + 0, msg[0]);
123-
nicvf_reg_write(nic, NIC_VF_PF_MAILBOX_0_1 + 8, msg[1]);
125+
nicvf_write_to_mbx(nic, mbx);
124126

125127
/* Wait for previous message to be acked, timeout 2sec */
126128
while (!nic->pf_acked) {
@@ -146,12 +148,13 @@ int nicvf_send_msg_to_pf(struct nicvf *nic, union nic_mbx *mbx)
146148
static int nicvf_check_pf_ready(struct nicvf *nic)
147149
{
148150
int timeout = 5000, sleep = 20;
151+
union nic_mbx mbx = {};
152+
153+
mbx.msg.msg = NIC_MBOX_MSG_READY;
149154

150155
nic->pf_ready_to_rcv_msg = false;
151156

152-
nicvf_reg_write(nic, NIC_VF_PF_MAILBOX_0_1 + 0,
153-
le64_to_cpu(NIC_MBOX_MSG_READY));
154-
nicvf_reg_write(nic, NIC_VF_PF_MAILBOX_0_1 + 8, 1ULL);
157+
nicvf_write_to_mbx(nic, &mbx);
155158

156159
while (!nic->pf_ready_to_rcv_msg) {
157160
msleep(sleep);
@@ -167,6 +170,14 @@ static int nicvf_check_pf_ready(struct nicvf *nic)
167170
return 1;
168171
}
169172

173+
static void nicvf_read_bgx_stats(struct nicvf *nic, struct bgx_stats_msg *bgx)
174+
{
175+
if (bgx->rx)
176+
nic->bgx_stats.rx_stats[bgx->idx] = bgx->stats;
177+
else
178+
nic->bgx_stats.tx_stats[bgx->idx] = bgx->stats;
179+
}
180+
170181
static void nicvf_handle_mbx_intr(struct nicvf *nic)
171182
{
172183
union nic_mbx mbx = {};
@@ -190,8 +201,7 @@ static void nicvf_handle_mbx_intr(struct nicvf *nic)
190201
nic->vf_id = mbx.nic_cfg.vf_id & 0x7F;
191202
nic->tns_mode = mbx.nic_cfg.tns_mode & 0x7F;
192203
nic->node = mbx.nic_cfg.node_id;
193-
ether_addr_copy(nic->netdev->dev_addr,
194-
(u8 *)&mbx.nic_cfg.mac_addr);
204+
ether_addr_copy(nic->netdev->dev_addr, mbx.nic_cfg.mac_addr);
195205
nic->link_up = false;
196206
nic->duplex = 0;
197207
nic->speed = 0;
@@ -241,18 +251,15 @@ static void nicvf_handle_mbx_intr(struct nicvf *nic)
241251
static int nicvf_hw_set_mac_addr(struct nicvf *nic, struct net_device *netdev)
242252
{
243253
union nic_mbx mbx = {};
244-
int i;
245254

246255
mbx.mac.msg = NIC_MBOX_MSG_SET_MAC;
247256
mbx.mac.vf_id = nic->vf_id;
248-
for (i = 0; i < ETH_ALEN; i++)
249-
mbx.mac.addr = (mbx.mac.addr << 8) |
250-
netdev->dev_addr[i];
257+
ether_addr_copy(mbx.mac.mac_addr, netdev->dev_addr);
251258

252259
return nicvf_send_msg_to_pf(nic, &mbx);
253260
}
254261

255-
void nicvf_config_cpi(struct nicvf *nic)
262+
static void nicvf_config_cpi(struct nicvf *nic)
256263
{
257264
union nic_mbx mbx = {};
258265

@@ -264,7 +271,7 @@ void nicvf_config_cpi(struct nicvf *nic)
264271
nicvf_send_msg_to_pf(nic, &mbx);
265272
}
266273

267-
void nicvf_get_rss_size(struct nicvf *nic)
274+
static void nicvf_get_rss_size(struct nicvf *nic)
268275
{
269276
union nic_mbx mbx = {};
270277

@@ -326,11 +333,11 @@ static int nicvf_rss_init(struct nicvf *nic)
326333
rss->enable = true;
327334

328335
/* Using the HW reset value for now */
329-
rss->key[0] = 0xFEED0BADFEED0BAD;
330-
rss->key[1] = 0xFEED0BADFEED0BAD;
331-
rss->key[2] = 0xFEED0BADFEED0BAD;
332-
rss->key[3] = 0xFEED0BADFEED0BAD;
333-
rss->key[4] = 0xFEED0BADFEED0BAD;
336+
rss->key[0] = 0xFEED0BADFEED0BADULL;
337+
rss->key[1] = 0xFEED0BADFEED0BADULL;
338+
rss->key[2] = 0xFEED0BADFEED0BADULL;
339+
rss->key[3] = 0xFEED0BADFEED0BADULL;
340+
rss->key[4] = 0xFEED0BADFEED0BADULL;
334341

335342
nicvf_set_rss_key(nic);
336343

@@ -368,7 +375,9 @@ int nicvf_set_real_num_queues(struct net_device *netdev,
368375
static int nicvf_init_resources(struct nicvf *nic)
369376
{
370377
int err;
371-
u64 mbx_addr = NIC_VF_PF_MAILBOX_0_1;
378+
union nic_mbx mbx = {};
379+
380+
mbx.msg.msg = NIC_MBOX_MSG_CFG_DONE;
372381

373382
/* Enable Qset */
374383
nicvf_qset_config(nic, true);
@@ -382,9 +391,7 @@ static int nicvf_init_resources(struct nicvf *nic)
382391
}
383392

384393
/* Send VF config done msg to PF */
385-
nicvf_reg_write(nic, mbx_addr, le64_to_cpu(NIC_MBOX_MSG_CFG_DONE));
386-
mbx_addr += (NIC_PF_VF_MAILBOX_SIZE - 1) * 8;
387-
nicvf_reg_write(nic, mbx_addr, 1ULL);
394+
nicvf_write_to_mbx(nic, &mbx);
388395

389396
return 0;
390397
}
@@ -572,7 +579,7 @@ static int nicvf_poll(struct napi_struct *napi, int budget)
572579
*
573580
* As of now only CQ errors are handled
574581
*/
575-
void nicvf_handle_qs_err(unsigned long data)
582+
static void nicvf_handle_qs_err(unsigned long data)
576583
{
577584
struct nicvf *nic = (struct nicvf *)data;
578585
struct queue_set *qs = nic->qs;
@@ -1040,14 +1047,6 @@ static int nicvf_set_mac_address(struct net_device *netdev, void *p)
10401047
return 0;
10411048
}
10421049

1043-
static void nicvf_read_bgx_stats(struct nicvf *nic, struct bgx_stats_msg *bgx)
1044-
{
1045-
if (bgx->rx)
1046-
nic->bgx_stats.rx_stats[bgx->idx] = bgx->stats;
1047-
else
1048-
nic->bgx_stats.tx_stats[bgx->idx] = bgx->stats;
1049-
}
1050-
10511050
void nicvf_update_lmac_stats(struct nicvf *nic)
10521051
{
10531052
int stat = 0;
@@ -1138,7 +1137,7 @@ void nicvf_update_stats(struct nicvf *nic)
11381137
nicvf_update_sq_stats(nic, qidx);
11391138
}
11401139

1141-
struct rtnl_link_stats64 *nicvf_get_stats64(struct net_device *netdev,
1140+
static struct rtnl_link_stats64 *nicvf_get_stats64(struct net_device *netdev,
11421141
struct rtnl_link_stats64 *stats)
11431142
{
11441143
struct nicvf *nic = netdev_priv(netdev);

drivers/net/ethernet/cavium/thunder/nicvf_queues.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ static int nicvf_alloc_q_desc_mem(struct nicvf *nic, struct q_desc_mem *dmem,
6262

6363
/* Align memory address for 'align_bytes' */
6464
dmem->phys_base = NICVF_ALIGNED_ADDR((u64)dmem->dma, align_bytes);
65-
dmem->base = (void *)((u8 *)dmem->unalign_base +
66-
(dmem->phys_base - dmem->dma));
65+
dmem->base = dmem->unalign_base + (dmem->phys_base - dmem->dma);
6766
return 0;
6867
}
6968

@@ -228,7 +227,7 @@ static void nicvf_free_rbdr(struct nicvf *nic, struct rbdr *rbdr)
228227

229228
/* Refill receive buffer descriptors with new buffers.
230229
*/
231-
void nicvf_refill_rbdr(struct nicvf *nic, gfp_t gfp)
230+
static void nicvf_refill_rbdr(struct nicvf *nic, gfp_t gfp)
232231
{
233232
struct queue_set *qs = nic->qs;
234233
int rbdr_idx = qs->rbdr_cnt;
@@ -357,7 +356,9 @@ static int nicvf_init_snd_queue(struct nicvf *nic,
357356
return err;
358357

359358
sq->desc = sq->dmem.base;
360-
sq->skbuff = kcalloc(q_len, sizeof(u64), GFP_ATOMIC);
359+
sq->skbuff = kcalloc(q_len, sizeof(u64), GFP_KERNEL);
360+
if (!sq->skbuff)
361+
return -ENOMEM;
361362
sq->head = 0;
362363
sq->tail = 0;
363364
atomic_set(&sq->free_cnt, q_len - 1);

drivers/net/ethernet/cavium/thunder/thunder_bgx.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct lmac {
3838
bool is_sgmii;
3939
struct delayed_work dwork;
4040
struct workqueue_struct *check_link;
41-
} lmac;
41+
};
4242

4343
struct bgx {
4444
u8 bgx_id;
@@ -50,9 +50,9 @@ struct bgx {
5050
int use_training;
5151
void __iomem *reg_base;
5252
struct pci_dev *pdev;
53-
} bgx;
53+
};
5454

55-
struct bgx *bgx_vnic[MAX_BGX_THUNDER];
55+
static struct bgx *bgx_vnic[MAX_BGX_THUNDER];
5656
static int lmac_count; /* Total no of LMACs in system */
5757

5858
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)
163163
}
164164
EXPORT_SYMBOL(bgx_get_lmac_link_state);
165165

166-
const char *bgx_get_lmac_mac(int node, int bgx_idx, int lmacid)
166+
const u8 *bgx_get_lmac_mac(int node, int bgx_idx, int lmacid)
167167
{
168168
struct bgx *bgx = bgx_vnic[(node * MAX_BGX_PER_CN88XX) + bgx_idx];
169169

@@ -174,7 +174,7 @@ const char *bgx_get_lmac_mac(int node, int bgx_idx, int lmacid)
174174
}
175175
EXPORT_SYMBOL(bgx_get_lmac_mac);
176176

177-
void bgx_set_lmac_mac(int node, int bgx_idx, int lmacid, const char *mac)
177+
void bgx_set_lmac_mac(int node, int bgx_idx, int lmacid, const u8 *mac)
178178
{
179179
struct bgx *bgx = bgx_vnic[(node * MAX_BGX_PER_CN88XX) + bgx_idx];
180180

@@ -253,7 +253,7 @@ static void bgx_sgmii_change_link_state(struct lmac *lmac)
253253
bgx_reg_write(bgx, lmac->lmacid, BGX_CMRX_CFG, cmr_cfg);
254254
}
255255

256-
void bgx_lmac_handler(struct net_device *netdev)
256+
static void bgx_lmac_handler(struct net_device *netdev)
257257
{
258258
struct lmac *lmac = container_of(netdev, struct lmac, netdev);
259259
struct phy_device *phydev = lmac->phydev;
@@ -655,7 +655,7 @@ static int bgx_lmac_enable(struct bgx *bgx, u8 lmacid)
655655
return 0;
656656
}
657657

658-
void bgx_lmac_disable(struct bgx *bgx, u8 lmacid)
658+
static void bgx_lmac_disable(struct bgx *bgx, u8 lmacid)
659659
{
660660
struct lmac *lmac;
661661
u64 cmrx_cfg;
@@ -894,8 +894,8 @@ static int bgx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
894894
goto err_release_regions;
895895
}
896896
bgx->bgx_id = (pci_resource_start(pdev, PCI_CFG_REG_BAR_NUM) >> 24) & 1;
897-
bgx->bgx_id += NODE_ID(pci_resource_start(pdev, PCI_CFG_REG_BAR_NUM))
898-
* MAX_BGX_PER_CN88XX;
897+
bgx->bgx_id += nic_get_node_id(pdev) * MAX_BGX_PER_CN88XX;
898+
899899
bgx_vnic[bgx->bgx_id] = bgx;
900900
bgx_get_qlm_mode(bgx);
901901

0 commit comments

Comments
 (0)