Skip to content

Commit 2f0b940

Browse files
RajuRangojudavem330
authored andcommitted
cxgb4: Add MPS TCAM refcounting for cxgb4 change mac
This patch adds TCAM reference counting support for cxgb4 change mac path Signed-off-by: Raju Rangoju <rajur@chelsio.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 5fab515 commit 2f0b940

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

drivers/net/ethernet/chelsio/cxgb4/cxgb4.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,6 +1911,10 @@ int cxgb4_set_msix_aff(struct adapter *adap, unsigned short vec,
19111911
cpumask_var_t *aff_mask, int idx);
19121912
void cxgb4_clear_msix_aff(unsigned short vec, cpumask_var_t aff_mask);
19131913

1914+
int cxgb4_change_mac(struct port_info *pi, unsigned int viid,
1915+
int *tcam_idx, const u8 *addr,
1916+
bool persistent, u8 *smt_idx);
1917+
19141918
int cxgb4_init_mps_ref_entries(struct adapter *adap);
19151919
void cxgb4_free_mps_ref_entries(struct adapter *adap);
19161920
int cxgb4_alloc_encap_mac_filt(struct adapter *adap, unsigned int viid,
@@ -1935,5 +1939,8 @@ int cxgb4_alloc_raw_mac_filt(struct adapter *adap,
19351939
u8 lookup_type,
19361940
u8 port_id,
19371941
bool sleep_ok);
1942+
int cxgb4_update_mac_filt(struct port_info *pi, unsigned int viid,
1943+
int *tcam_idx, const u8 *addr,
1944+
bool persistent, u8 *smt_idx);
19381945

19391946
#endif /* __CXGB4_H__ */

drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -449,9 +449,9 @@ static int set_rxmode(struct net_device *dev, int mtu, bool sleep_ok)
449449
* Addresses are programmed to hash region, if tcam runs out of entries.
450450
*
451451
*/
452-
static int cxgb4_change_mac(struct port_info *pi, unsigned int viid,
453-
int *tcam_idx, const u8 *addr, bool persist,
454-
u8 *smt_idx)
452+
int cxgb4_change_mac(struct port_info *pi, unsigned int viid,
453+
int *tcam_idx, const u8 *addr, bool persist,
454+
u8 *smt_idx)
455455
{
456456
struct adapter *adapter = pi->adapter;
457457
struct hash_mac_addr *entry, *new_entry;
@@ -505,8 +505,8 @@ static int link_start(struct net_device *dev)
505505
ret = t4_set_rxmode(pi->adapter, mb, pi->viid, dev->mtu, -1, -1, -1,
506506
!!(dev->features & NETIF_F_HW_VLAN_CTAG_RX), true);
507507
if (ret == 0)
508-
ret = cxgb4_change_mac(pi, pi->viid, &pi->xact_addr_filt,
509-
dev->dev_addr, true, &pi->smt_idx);
508+
ret = cxgb4_update_mac_filt(pi, pi->viid, &pi->xact_addr_filt,
509+
dev->dev_addr, true, &pi->smt_idx);
510510
if (ret == 0)
511511
ret = t4_link_l1cfg(pi->adapter, mb, pi->tx_chan,
512512
&pi->link_cfg);
@@ -3020,8 +3020,8 @@ static int cxgb_set_mac_addr(struct net_device *dev, void *p)
30203020
if (!is_valid_ether_addr(addr->sa_data))
30213021
return -EADDRNOTAVAIL;
30223022

3023-
ret = cxgb4_change_mac(pi, pi->viid, &pi->xact_addr_filt,
3024-
addr->sa_data, true, &pi->smt_idx);
3023+
ret = cxgb4_update_mac_filt(pi, pi->viid, &pi->xact_addr_filt,
3024+
addr->sa_data, true, &pi->smt_idx);
30253025
if (ret < 0)
30263026
return ret;
30273027

drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,21 @@ static int cxgb4_mps_ref_inc(struct adapter *adap, const u8 *mac_addr,
5454
return ret;
5555
}
5656

57+
int cxgb4_update_mac_filt(struct port_info *pi, unsigned int viid,
58+
int *tcam_idx, const u8 *addr,
59+
bool persistent, u8 *smt_idx)
60+
{
61+
int ret;
62+
63+
ret = cxgb4_change_mac(pi, viid, tcam_idx,
64+
addr, persistent, smt_idx);
65+
if (ret < 0)
66+
return ret;
67+
68+
cxgb4_mps_ref_inc(pi->adapter, addr, *tcam_idx, NULL);
69+
return ret;
70+
}
71+
5772
int cxgb4_free_raw_mac_filt(struct adapter *adap,
5873
unsigned int viid,
5974
const u8 *addr,

0 commit comments

Comments
 (0)