From 28b3870578ef403000c99d54c40fffb0210ff70d Mon Sep 17 00:00:00 2001 From: Raju Rangoju Date: Mon, 24 Jun 2019 23:05:32 +0530 Subject: cxgb4: Re-work the logic for mps refcounting Remove existing mps refcounting code which was added only for encap filters and add necessary data structures/functions to support mps reference counting for all the mac filters. Also add wrapper functions for allocating and freeing encap mac filters. Signed-off-by: Raju Rangoju Signed-off-by: David S. Miller --- drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'drivers/net/ethernet/chelsio/cxgb4/cxgb4.h') diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h index db2ec46ba6b6..39ccd4c64d48 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h @@ -905,10 +905,6 @@ struct mbox_list { struct list_head list; }; -struct mps_encap_entry { - atomic_t refcnt; -}; - #if IS_ENABLED(CONFIG_THERMAL) struct ch_thermal { struct thermal_zone_device *tzdev; @@ -917,6 +913,14 @@ struct ch_thermal { }; #endif +struct mps_entries_ref { + struct list_head list; + u8 addr[ETH_ALEN]; + u8 mask[ETH_ALEN]; + u16 idx; + refcount_t refcnt; +}; + struct adapter { void __iomem *regs; void __iomem *bar2; @@ -969,7 +973,6 @@ struct adapter { unsigned int rawf_start; unsigned int rawf_cnt; struct smt_data *smt; - struct mps_encap_entry *mps_encap; struct cxgb4_uld_info *uld; void *uld_handle[CXGB4_ULD_MAX]; unsigned int num_uld; @@ -977,6 +980,8 @@ struct adapter { struct list_head list_node; struct list_head rcu_node; struct list_head mac_hlist; /* list of MAC addresses in MPS Hash */ + struct list_head mps_ref; + spinlock_t mps_ref_lock; /* lock for syncing mps ref/def activities */ void *iscsi_ppm; @@ -1906,4 +1911,13 @@ int cxgb4_set_msix_aff(struct adapter *adap, unsigned short vec, cpumask_var_t *aff_mask, int idx); void cxgb4_clear_msix_aff(unsigned short vec, cpumask_var_t aff_mask); +int cxgb4_init_mps_ref_entries(struct adapter *adap); +void cxgb4_free_mps_ref_entries(struct adapter *adap); +int cxgb4_alloc_encap_mac_filt(struct adapter *adap, unsigned int viid, + const u8 *addr, const u8 *mask, + unsigned int vni, unsigned int vni_mask, + u8 dip_hit, u8 lookup_type, bool sleep_ok); +int cxgb4_free_encap_mac_filt(struct adapter *adap, unsigned int viid, + int idx, bool sleep_ok); + #endif /* __CXGB4_H__ */ -- cgit From 5fab51581f6223adab8dc7b526fe1217eb3b7348 Mon Sep 17 00:00:00 2001 From: Raju Rangoju Date: Mon, 24 Jun 2019 23:05:33 +0530 Subject: cxgb4: Add MPS TCAM refcounting for raw mac filters This patch adds TCAM reference counting support for raw mac filters. Signed-off-by: Raju Rangoju Signed-off-by: David S. Miller --- drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'drivers/net/ethernet/chelsio/cxgb4/cxgb4.h') diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h index 39ccd4c64d48..c7ab57fd03be 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h @@ -1919,5 +1919,21 @@ int cxgb4_alloc_encap_mac_filt(struct adapter *adap, unsigned int viid, u8 dip_hit, u8 lookup_type, bool sleep_ok); int cxgb4_free_encap_mac_filt(struct adapter *adap, unsigned int viid, int idx, bool sleep_ok); +int cxgb4_free_raw_mac_filt(struct adapter *adap, + unsigned int viid, + const u8 *addr, + const u8 *mask, + unsigned int idx, + u8 lookup_type, + u8 port_id, + bool sleep_ok); +int cxgb4_alloc_raw_mac_filt(struct adapter *adap, + unsigned int viid, + const u8 *addr, + const u8 *mask, + unsigned int idx, + u8 lookup_type, + u8 port_id, + bool sleep_ok); #endif /* __CXGB4_H__ */ -- cgit From 2f0b9406f3c77491928b8c6c855ef8349eff31ac Mon Sep 17 00:00:00 2001 From: Raju Rangoju Date: Mon, 24 Jun 2019 23:05:34 +0530 Subject: 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 Signed-off-by: David S. Miller --- drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers/net/ethernet/chelsio/cxgb4/cxgb4.h') diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h index c7ab57fd03be..6260240743d5 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h @@ -1911,6 +1911,10 @@ int cxgb4_set_msix_aff(struct adapter *adap, unsigned short vec, cpumask_var_t *aff_mask, int idx); void cxgb4_clear_msix_aff(unsigned short vec, cpumask_var_t aff_mask); +int cxgb4_change_mac(struct port_info *pi, unsigned int viid, + int *tcam_idx, const u8 *addr, + bool persistent, u8 *smt_idx); + int cxgb4_init_mps_ref_entries(struct adapter *adap); void cxgb4_free_mps_ref_entries(struct adapter *adap); 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, u8 lookup_type, u8 port_id, bool sleep_ok); +int cxgb4_update_mac_filt(struct port_info *pi, unsigned int viid, + int *tcam_idx, const u8 *addr, + bool persistent, u8 *smt_idx); #endif /* __CXGB4_H__ */ -- cgit From f9f329ad87c746f4e6e352eb035e70b0dd7d5643 Mon Sep 17 00:00:00 2001 From: Raju Rangoju Date: Mon, 24 Jun 2019 23:05:35 +0530 Subject: cxgb4: Add MPS refcounting for alloc/free mac filters This patch adds reference counting support for alloc/free mac filters Signed-off-by: Raju Rangoju Signed-off-by: David S. Miller --- drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers/net/ethernet/chelsio/cxgb4/cxgb4.h') diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h index 6260240743d5..1fbb640e896a 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h @@ -1915,6 +1915,12 @@ int cxgb4_change_mac(struct port_info *pi, unsigned int viid, int *tcam_idx, const u8 *addr, bool persistent, u8 *smt_idx); +int cxgb4_alloc_mac_filt(struct adapter *adap, unsigned int viid, + bool free, unsigned int naddr, + const u8 **addr, u16 *idx, + u64 *hash, bool sleep_ok); +int cxgb4_free_mac_filt(struct adapter *adap, unsigned int viid, + unsigned int naddr, const u8 **addr, bool sleep_ok); int cxgb4_init_mps_ref_entries(struct adapter *adap); void cxgb4_free_mps_ref_entries(struct adapter *adap); int cxgb4_alloc_encap_mac_filt(struct adapter *adap, unsigned int viid, -- cgit