Skip to content

Commit a59cf61

Browse files
committed
Merge branch 'Fix-bugs-in-Octeontx2-netdev-driver'
Geetha sowjanya says: ==================== Fix bugs in Octeontx2 netdev driver In existing Octeontx2 network drivers code has issues like stale entries in broadcast replication list, missing L3TYPE for IPv6 frames, running tx queues on error and race condition in mbox reset. This patch set fixes the above issues. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 03e7e72 + 66a5209 commit a59cf61

File tree

8 files changed

+47
-21
lines changed

8 files changed

+47
-21
lines changed

drivers/net/ethernet/marvell/octeontx2/af/mbox.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
static const u16 msgs_offset = ALIGN(sizeof(struct mbox_hdr), MBOX_MSG_ALIGN);
1919

20-
void otx2_mbox_reset(struct otx2_mbox *mbox, int devid)
20+
void __otx2_mbox_reset(struct otx2_mbox *mbox, int devid)
2121
{
2222
void *hw_mbase = mbox->hwbase + (devid * MBOX_SIZE);
2323
struct otx2_mbox_dev *mdev = &mbox->dev[devid];
@@ -26,13 +26,21 @@ void otx2_mbox_reset(struct otx2_mbox *mbox, int devid)
2626
tx_hdr = hw_mbase + mbox->tx_start;
2727
rx_hdr = hw_mbase + mbox->rx_start;
2828

29-
spin_lock(&mdev->mbox_lock);
3029
mdev->msg_size = 0;
3130
mdev->rsp_size = 0;
3231
tx_hdr->num_msgs = 0;
3332
tx_hdr->msg_size = 0;
3433
rx_hdr->num_msgs = 0;
3534
rx_hdr->msg_size = 0;
35+
}
36+
EXPORT_SYMBOL(__otx2_mbox_reset);
37+
38+
void otx2_mbox_reset(struct otx2_mbox *mbox, int devid)
39+
{
40+
struct otx2_mbox_dev *mdev = &mbox->dev[devid];
41+
42+
spin_lock(&mdev->mbox_lock);
43+
__otx2_mbox_reset(mbox, devid);
3644
spin_unlock(&mdev->mbox_lock);
3745
}
3846
EXPORT_SYMBOL(otx2_mbox_reset);

drivers/net/ethernet/marvell/octeontx2/af/mbox.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ struct mbox_msghdr {
9393
};
9494

9595
void otx2_mbox_reset(struct otx2_mbox *mbox, int devid);
96+
void __otx2_mbox_reset(struct otx2_mbox *mbox, int devid);
9697
void otx2_mbox_destroy(struct otx2_mbox *mbox);
9798
int otx2_mbox_init(struct otx2_mbox *mbox, void __force *hwbase,
9899
struct pci_dev *pdev, void __force *reg_base,

drivers/net/ethernet/marvell/octeontx2/af/rvu.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ void rvu_nix_freemem(struct rvu *rvu);
463463
int rvu_get_nixlf_count(struct rvu *rvu);
464464
void rvu_nix_lf_teardown(struct rvu *rvu, u16 pcifunc, int blkaddr, int npalf);
465465
int nix_get_nixlf(struct rvu *rvu, u16 pcifunc, int *nixlf, int *nix_blkaddr);
466+
int nix_update_bcast_mce_list(struct rvu *rvu, u16 pcifunc, bool add);
466467

467468
/* NPC APIs */
468469
int rvu_npc_init(struct rvu *rvu);
@@ -477,7 +478,7 @@ void rvu_npc_disable_promisc_entry(struct rvu *rvu, u16 pcifunc, int nixlf);
477478
void rvu_npc_enable_promisc_entry(struct rvu *rvu, u16 pcifunc, int nixlf);
478479
void rvu_npc_install_bcast_match_entry(struct rvu *rvu, u16 pcifunc,
479480
int nixlf, u64 chan);
480-
void rvu_npc_disable_bcast_entry(struct rvu *rvu, u16 pcifunc);
481+
void rvu_npc_enable_bcast_entry(struct rvu *rvu, u16 pcifunc, bool enable);
481482
int rvu_npc_update_rxvlan(struct rvu *rvu, u16 pcifunc, int nixlf);
482483
void rvu_npc_disable_mcam_entries(struct rvu *rvu, u16 pcifunc, int nixlf);
483484
void rvu_npc_disable_default_entries(struct rvu *rvu, u16 pcifunc, int nixlf);

drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "npc.h"
1818
#include "cgx.h"
1919

20-
static int nix_update_bcast_mce_list(struct rvu *rvu, u16 pcifunc, bool add);
2120
static int rvu_nix_get_bpid(struct rvu *rvu, struct nix_bp_cfg_req *req,
2221
int type, int chan_id);
2322

@@ -2020,7 +2019,7 @@ static int nix_update_mce_list(struct nix_mce_list *mce_list,
20202019
return 0;
20212020
}
20222021

2023-
static int nix_update_bcast_mce_list(struct rvu *rvu, u16 pcifunc, bool add)
2022+
int nix_update_bcast_mce_list(struct rvu *rvu, u16 pcifunc, bool add)
20242023
{
20252024
int err = 0, idx, next_idx, last_idx;
20262025
struct nix_mce_list *mce_list;
@@ -2065,7 +2064,7 @@ static int nix_update_bcast_mce_list(struct rvu *rvu, u16 pcifunc, bool add)
20652064

20662065
/* Disable MCAM entry in NPC */
20672066
if (!mce_list->count) {
2068-
rvu_npc_disable_bcast_entry(rvu, pcifunc);
2067+
rvu_npc_enable_bcast_entry(rvu, pcifunc, false);
20692068
goto end;
20702069
}
20712070

drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ void rvu_npc_install_bcast_match_entry(struct rvu *rvu, u16 pcifunc,
530530
NIX_INTF_RX, &entry, true);
531531
}
532532

533-
void rvu_npc_disable_bcast_entry(struct rvu *rvu, u16 pcifunc)
533+
void rvu_npc_enable_bcast_entry(struct rvu *rvu, u16 pcifunc, bool enable)
534534
{
535535
struct npc_mcam *mcam = &rvu->hw->mcam;
536536
int blkaddr, index;
@@ -543,7 +543,7 @@ void rvu_npc_disable_bcast_entry(struct rvu *rvu, u16 pcifunc)
543543
pcifunc = pcifunc & ~RVU_PFVF_FUNC_MASK;
544544

545545
index = npc_get_nixlf_mcam_index(mcam, pcifunc, 0, NIXLF_BCAST_ENTRY);
546-
npc_enable_mcam_entry(rvu, mcam, blkaddr, index, false);
546+
npc_enable_mcam_entry(rvu, mcam, blkaddr, index, enable);
547547
}
548548

549549
void rvu_npc_update_flowkey_alg_idx(struct rvu *rvu, u16 pcifunc, int nixlf,
@@ -622,23 +622,35 @@ static void npc_enadis_default_entries(struct rvu *rvu, u16 pcifunc,
622622
nixlf, NIXLF_UCAST_ENTRY);
623623
npc_enable_mcam_entry(rvu, mcam, blkaddr, index, enable);
624624

625-
/* For PF, ena/dis promisc and bcast MCAM match entries */
626-
if (pcifunc & RVU_PFVF_FUNC_MASK)
625+
/* For PF, ena/dis promisc and bcast MCAM match entries.
626+
* For VFs add/delete from bcast list when RX multicast
627+
* feature is present.
628+
*/
629+
if (pcifunc & RVU_PFVF_FUNC_MASK && !rvu->hw->cap.nix_rx_multicast)
627630
return;
628631

629632
/* For bcast, enable/disable only if it's action is not
630633
* packet replication, incase if action is replication
631-
* then this PF's nixlf is removed from bcast replication
634+
* then this PF/VF's nixlf is removed from bcast replication
632635
* list.
633636
*/
634-
index = npc_get_nixlf_mcam_index(mcam, pcifunc,
637+
index = npc_get_nixlf_mcam_index(mcam, pcifunc & ~RVU_PFVF_FUNC_MASK,
635638
nixlf, NIXLF_BCAST_ENTRY);
636639
bank = npc_get_bank(mcam, index);
637640
*(u64 *)&action = rvu_read64(rvu, blkaddr,
638641
NPC_AF_MCAMEX_BANKX_ACTION(index & (mcam->banksize - 1), bank));
639-
if (action.op != NIX_RX_ACTIONOP_MCAST)
642+
643+
/* VFs will not have BCAST entry */
644+
if (action.op != NIX_RX_ACTIONOP_MCAST &&
645+
!(pcifunc & RVU_PFVF_FUNC_MASK)) {
640646
npc_enable_mcam_entry(rvu, mcam,
641647
blkaddr, index, enable);
648+
} else {
649+
nix_update_bcast_mce_list(rvu, pcifunc, enable);
650+
/* Enable PF's BCAST entry for packet replication */
651+
rvu_npc_enable_bcast_entry(rvu, pcifunc, enable);
652+
}
653+
642654
if (enable)
643655
rvu_npc_enable_promisc_entry(rvu, pcifunc, nixlf);
644656
else

drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@ static int otx2_forward_vf_mbox_msgs(struct otx2_nic *pf,
370370
dst_mbox = &pf->mbox;
371371
dst_size = dst_mbox->mbox.tx_size -
372372
ALIGN(sizeof(*mbox_hdr), MBOX_MSG_ALIGN);
373-
/* Check if msgs fit into destination area */
374-
if (mbox_hdr->msg_size > dst_size)
373+
/* Check if msgs fit into destination area and has valid size */
374+
if (mbox_hdr->msg_size > dst_size || !mbox_hdr->msg_size)
375375
return -EINVAL;
376376

377377
dst_mdev = &dst_mbox->mbox.dev[0];
@@ -526,10 +526,10 @@ static void otx2_pfvf_mbox_up_handler(struct work_struct *work)
526526

527527
end:
528528
offset = mbox->rx_start + msg->next_msgoff;
529+
if (mdev->msgs_acked == (vf_mbox->up_num_msgs - 1))
530+
__otx2_mbox_reset(mbox, 0);
529531
mdev->msgs_acked++;
530532
}
531-
532-
otx2_mbox_reset(mbox, vf_idx);
533533
}
534534

535535
static irqreturn_t otx2_pfvf_mbox_intr_handler(int irq, void *pf_irq)
@@ -803,10 +803,11 @@ static void otx2_pfaf_mbox_handler(struct work_struct *work)
803803
msg = (struct mbox_msghdr *)(mdev->mbase + offset);
804804
otx2_process_pfaf_mbox_msg(pf, msg);
805805
offset = mbox->rx_start + msg->next_msgoff;
806+
if (mdev->msgs_acked == (af_mbox->num_msgs - 1))
807+
__otx2_mbox_reset(mbox, 0);
806808
mdev->msgs_acked++;
807809
}
808810

809-
otx2_mbox_reset(mbox, 0);
810811
}
811812

812813
static void otx2_handle_link_event(struct otx2_nic *pf)
@@ -1560,10 +1561,13 @@ int otx2_open(struct net_device *netdev)
15601561

15611562
err = otx2_rxtx_enable(pf, true);
15621563
if (err)
1563-
goto err_free_cints;
1564+
goto err_tx_stop_queues;
15641565

15651566
return 0;
15661567

1568+
err_tx_stop_queues:
1569+
netif_tx_stop_all_queues(netdev);
1570+
netif_carrier_off(netdev);
15671571
err_free_cints:
15681572
otx2_free_cints(pf, qidx);
15691573
vec = pci_irq_vector(pf->pdev,

drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@ static void otx2_sqe_add_hdr(struct otx2_nic *pfvf, struct otx2_snd_queue *sq,
524524
sqe_hdr->ol3type = NIX_SENDL3TYPE_IP4_CKSUM;
525525
} else if (skb->protocol == htons(ETH_P_IPV6)) {
526526
proto = ipv6_hdr(skb)->nexthdr;
527+
sqe_hdr->ol3type = NIX_SENDL3TYPE_IP6;
527528
}
528529

529530
if (proto == IPPROTO_TCP)

drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ static void otx2vf_vfaf_mbox_handler(struct work_struct *work)
9999
msg = (struct mbox_msghdr *)(mdev->mbase + offset);
100100
otx2vf_process_vfaf_mbox_msg(af_mbox->pfvf, msg);
101101
offset = mbox->rx_start + msg->next_msgoff;
102+
if (mdev->msgs_acked == (af_mbox->num_msgs - 1))
103+
__otx2_mbox_reset(mbox, 0);
102104
mdev->msgs_acked++;
103105
}
104-
105-
otx2_mbox_reset(mbox, 0);
106106
}
107107

108108
static int otx2vf_process_mbox_msg_up(struct otx2_nic *vf,

0 commit comments

Comments
 (0)