Skip to content

Commit 2f38752

Browse files
Hariprasad Kelamdavem330
authored andcommitted
octeontx2-af: Add validation of lmac
With the addition of new MAC blocks like CN10K RPM and CN10KB RPM_USX, LMACs are noncontiguous. Though in most of the functions, lmac validation checks exist but in few functions they are missing. This patch adds the same. Signed-off-by: Hariprasad Kelam <hkelam@marvell.com> Signed-off-by: Sunil Kovvuri Goutham <sgoutham@marvell.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f027fd5 commit 2f38752

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

  • drivers/net/ethernet/marvell/octeontx2/af

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ int cgx_lmac_addr_set(u8 cgx_id, u8 lmac_id, u8 *mac_addr)
232232
int index, id;
233233
u64 cfg;
234234

235+
if (!lmac)
236+
return -ENODEV;
237+
235238
/* access mac_ops to know csr_offset */
236239
mac_ops = cgx_dev->mac_ops;
237240

@@ -550,15 +553,16 @@ void cgx_lmac_promisc_config(int cgx_id, int lmac_id, bool enable)
550553
{
551554
struct cgx *cgx = cgx_get_pdata(cgx_id);
552555
struct lmac *lmac = lmac_pdata(lmac_id, cgx);
553-
u16 max_dmac = lmac->mac_to_index_bmap.max;
554556
struct mac_ops *mac_ops;
557+
u16 max_dmac;
555558
int index, i;
556559
u64 cfg = 0;
557560
int id;
558561

559-
if (!cgx)
562+
if (!cgx || !lmac)
560563
return;
561564

565+
max_dmac = lmac->mac_to_index_bmap.max;
562566
id = get_sequence_id_of_lmac(cgx, lmac_id);
563567

564568
mac_ops = cgx->mac_ops;
@@ -731,7 +735,7 @@ int cgx_get_fec_stats(void *cgxd, int lmac_id, struct cgx_fec_stats_rsp *rsp)
731735
int corr_reg, uncorr_reg;
732736
struct cgx *cgx = cgxd;
733737

734-
if (!cgx || lmac_id >= cgx->lmac_count)
738+
if (!is_lmac_valid(cgx, lmac_id))
735739
return -ENODEV;
736740

737741
if (cgx->lmac_idmap[lmac_id]->link_info.fec == OTX2_FEC_NONE)

0 commit comments

Comments
 (0)