netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 net-next 0/4] cxgb4: Reference count MPS TCAM entries within a PF
@ 2019-06-24  8:50 Raju Rangoju
  2019-06-24  8:50 ` [PATCH v2 net-next 1/4] cxgb4: Re-work the logic for mps refcounting Raju Rangoju
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Raju Rangoju @ 2019-06-24  8:50 UTC (permalink / raw)
  To: netdev, davem; +Cc: nirranjan, dt, rajur

Firmware reference counts the MPS TCAM entries by PF and VF,
but it does not do it for usage within a PF or VF. This patch
adds the support to track MPS TCAM entries within a PF.

v1->v2:
 Use refcount_t type instead of atomic_t for mps reference count

Raju Rangoju (4):
  cxgb4: Re-work the logic for mps refcounting
  cxgb4: Add MPS TCAM refcounting for raw mac filters
  cxgb4: Add MPS TCAM refcounting for cxgb4 change mac
  cxgb4: Add MPS refcounting for alloc/free mac filters

 drivers/net/ethernet/chelsio/cxgb4/Makefile       |   2 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h        |  53 ++++-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c |   8 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c   |  40 ++--
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c    | 242 ++++++++++++++++++++++
 5 files changed, 313 insertions(+), 32 deletions(-)
 create mode 100644 drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c

-- 
2.12.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v2 net-next 1/4] cxgb4: Re-work the logic for mps refcounting
  2019-06-24  8:50 [PATCH v2 net-next 0/4] cxgb4: Reference count MPS TCAM entries within a PF Raju Rangoju
@ 2019-06-24  8:50 ` Raju Rangoju
  2019-06-24  8:50 ` [PATCH v2 net-next 2/4] cxgb4: Add MPS TCAM refcounting for raw mac filters Raju Rangoju
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 13+ messages in thread
From: Raju Rangoju @ 2019-06-24  8:50 UTC (permalink / raw)
  To: netdev, davem; +Cc: nirranjan, dt, rajur

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 <rajur@chelsio.com>
---
 drivers/net/ethernet/chelsio/cxgb4/Makefile       |   2 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h        |  24 ++++-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c |   8 +-
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c   |  14 +--
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c    | 109 ++++++++++++++++++++++
 5 files changed, 135 insertions(+), 22 deletions(-)
 create mode 100644 drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c

diff --git a/drivers/net/ethernet/chelsio/cxgb4/Makefile b/drivers/net/ethernet/chelsio/cxgb4/Makefile
index 91d8a885deba..20390f6afbb4 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/Makefile
+++ b/drivers/net/ethernet/chelsio/cxgb4/Makefile
@@ -7,7 +7,7 @@ obj-$(CONFIG_CHELSIO_T4) += cxgb4.o
 
 cxgb4-objs := cxgb4_main.o l2t.o smt.o t4_hw.o sge.o clip_tbl.o cxgb4_ethtool.o \
 	      cxgb4_uld.o srq.o sched.o cxgb4_filter.o cxgb4_tc_u32.o \
-	      cxgb4_ptp.o cxgb4_tc_flower.o cxgb4_cudbg.o \
+	      cxgb4_ptp.o cxgb4_tc_flower.o cxgb4_cudbg.o cxgb4_mps.o \
 	      cudbg_common.o cudbg_lib.o cudbg_zlib.o
 cxgb4-$(CONFIG_CHELSIO_T4_DCB) +=  cxgb4_dcb.o
 cxgb4-$(CONFIG_CHELSIO_T4_FCOE) +=  cxgb4_fcoe.o
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__ */
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
index 6232236d7abc..43b0f8c57da7 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
@@ -727,10 +727,8 @@ void clear_filter(struct adapter *adap, struct filter_entry *f)
 		cxgb4_smt_release(f->smt);
 
 	if (f->fs.val.encap_vld && f->fs.val.ovlan_vld)
-		if (atomic_dec_and_test(&adap->mps_encap[f->fs.val.ovlan &
-							 0x1ff].refcnt))
-			t4_free_encap_mac_filt(adap, pi->viid,
-					       f->fs.val.ovlan & 0x1ff, 0);
+		t4_free_encap_mac_filt(adap, pi->viid,
+				       f->fs.val.ovlan & 0x1ff, 0);
 
 	if ((f->fs.hash || is_t6(adap->params.chip)) && f->fs.type)
 		cxgb4_clip_release(f->dev, (const u32 *)&f->fs.val.lip, 1);
@@ -1177,7 +1175,6 @@ static int cxgb4_set_hash_filter(struct net_device *dev,
 			if (ret < 0)
 				goto free_atid;
 
-			atomic_inc(&adapter->mps_encap[ret].refcnt);
 			f->fs.val.ovlan = ret;
 			f->fs.mask.ovlan = 0xffff;
 			f->fs.val.ovlan_vld = 1;
@@ -1420,7 +1417,6 @@ int __cxgb4_set_filter(struct net_device *dev, int filter_id,
 			if (ret < 0)
 				goto free_clip;
 
-			atomic_inc(&adapter->mps_encap[ret].refcnt);
 			f->fs.val.ovlan = ret;
 			f->fs.mask.ovlan = 0x1ff;
 			f->fs.val.ovlan_vld = 1;
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 54908002c786..4632827f05ba 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -3273,8 +3273,6 @@ static void cxgb_del_udp_tunnel(struct net_device *netdev,
 				    i);
 			return;
 		}
-		atomic_dec(&adapter->mps_encap[adapter->rawf_start +
-			   pi->port_id].refcnt);
 	}
 }
 
@@ -3363,7 +3361,6 @@ static void cxgb_add_udp_tunnel(struct net_device *netdev,
 			cxgb_del_udp_tunnel(netdev, ti);
 			return;
 		}
-		atomic_inc(&adapter->mps_encap[ret].refcnt);
 	}
 }
 
@@ -5446,7 +5443,6 @@ static void free_some_resources(struct adapter *adapter)
 {
 	unsigned int i;
 
-	kvfree(adapter->mps_encap);
 	kvfree(adapter->smt);
 	kvfree(adapter->l2t);
 	kvfree(adapter->srq);
@@ -5972,12 +5968,6 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 		adapter->params.offload = 0;
 	}
 
-	adapter->mps_encap = kvcalloc(adapter->params.arch.mps_tcam_size,
-				      sizeof(struct mps_encap_entry),
-				      GFP_KERNEL);
-	if (!adapter->mps_encap)
-		dev_warn(&pdev->dev, "could not allocate MPS Encap entries, continuing\n");
-
 #if IS_ENABLED(CONFIG_IPV6)
 	if (chip_ver <= CHELSIO_T5 &&
 	    (!(t4_read_reg(adapter, LE_DB_CONFIG_A) & ASLIPCOMPEN_F))) {
@@ -6053,6 +6043,8 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	/* check for PCI Express bandwidth capabiltites */
 	pcie_print_link_status(pdev);
 
+	cxgb4_init_mps_ref_entries(adapter);
+
 	err = init_rss(adapter);
 	if (err)
 		goto out_free_dev;
@@ -6179,6 +6171,8 @@ static void remove_one(struct pci_dev *pdev)
 
 		disable_interrupts(adapter);
 
+		cxgb4_free_mps_ref_entries(adapter);
+
 		for_each_port(adapter, i)
 			if (adapter->port[i]->reg_state == NETREG_REGISTERED)
 				unregister_netdev(adapter->port[i]);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c
new file mode 100644
index 000000000000..ab8f1ade981a
--- /dev/null
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c
@@ -0,0 +1,109 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2019 Chelsio Communications, Inc. All rights reserved. */
+
+#include "cxgb4.h"
+
+static int cxgb4_mps_ref_dec(struct adapter *adap, u16 idx)
+{
+	struct mps_entries_ref *mps_entry, *tmp;
+	int ret = -EINVAL;
+
+	spin_lock(&adap->mps_ref_lock);
+	list_for_each_entry_safe(mps_entry, tmp, &adap->mps_ref, list) {
+		if (mps_entry->idx == idx) {
+			if (!refcount_dec_and_test(&mps_entry->refcnt)) {
+				spin_unlock(&adap->mps_ref_lock);
+				return -EBUSY;
+			}
+			list_del(&mps_entry->list);
+			kfree(mps_entry);
+			ret = 0;
+			break;
+		}
+	}
+	spin_unlock(&adap->mps_ref_lock);
+	return ret;
+}
+
+static int cxgb4_mps_ref_inc(struct adapter *adap, const u8 *mac_addr,
+			     u16 idx, const u8 *mask)
+{
+	u8 bitmask[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+	struct mps_entries_ref *mps_entry;
+	int ret = 0;
+
+	spin_lock_bh(&adap->mps_ref_lock);
+	list_for_each_entry(mps_entry, &adap->mps_ref, list) {
+		if (mps_entry->idx == idx) {
+			refcount_inc(&mps_entry->refcnt);
+			goto unlock;
+		}
+	}
+	mps_entry = kzalloc(sizeof(*mps_entry), GFP_ATOMIC);
+	if (!mps_entry) {
+		ret = -ENOMEM;
+		goto unlock;
+	}
+	ether_addr_copy(mps_entry->mask, mask ? mask : bitmask);
+	ether_addr_copy(mps_entry->addr, mac_addr);
+	mps_entry->idx = idx;
+	refcount_set(&mps_entry->refcnt, 1);
+	list_add_tail(&mps_entry->list, &adap->mps_ref);
+unlock:
+	spin_unlock_bh(&adap->mps_ref_lock);
+	return ret;
+}
+
+int cxgb4_free_encap_mac_filt(struct adapter *adap, unsigned int viid,
+			      int idx, bool sleep_ok)
+{
+	int ret = 0;
+
+	if (!cxgb4_mps_ref_dec(adap, idx))
+		ret = t4_free_encap_mac_filt(adap, viid, idx, sleep_ok);
+
+	return ret;
+}
+
+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 ret;
+
+	ret = t4_alloc_encap_mac_filt(adap, viid, addr, mask, vni, vni_mask,
+				      dip_hit, lookup_type, sleep_ok);
+	if (ret < 0)
+		return ret;
+
+	if (cxgb4_mps_ref_inc(adap, addr, ret, mask)) {
+		ret = -ENOMEM;
+		t4_free_encap_mac_filt(adap, viid, ret, sleep_ok);
+	}
+	return ret;
+}
+
+int cxgb4_init_mps_ref_entries(struct adapter *adap)
+{
+	spin_lock_init(&adap->mps_ref_lock);
+	INIT_LIST_HEAD(&adap->mps_ref);
+
+	return 0;
+}
+
+void cxgb4_free_mps_ref_entries(struct adapter *adap)
+{
+	struct mps_entries_ref *mps_entry, *tmp;
+
+	if (!list_empty(&adap->mps_ref))
+		return;
+
+	spin_lock(&adap->mps_ref_lock);
+	list_for_each_entry_safe(mps_entry, tmp, &adap->mps_ref, list) {
+		list_del(&mps_entry->list);
+		kfree(mps_entry);
+	}
+	spin_unlock(&adap->mps_ref_lock);
+}
+
-- 
2.12.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 net-next 2/4] cxgb4: Add MPS TCAM refcounting for raw mac filters
  2019-06-24  8:50 [PATCH v2 net-next 0/4] cxgb4: Reference count MPS TCAM entries within a PF Raju Rangoju
  2019-06-24  8:50 ` [PATCH v2 net-next 1/4] cxgb4: Re-work the logic for mps refcounting Raju Rangoju
@ 2019-06-24  8:50 ` Raju Rangoju
  2019-06-24  8:50 ` [PATCH v2 net-next 3/4] cxgb4: Add MPS TCAM refcounting for cxgb4 change mac Raju Rangoju
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 13+ messages in thread
From: Raju Rangoju @ 2019-06-24  8:50 UTC (permalink / raw)
  To: netdev, davem; +Cc: nirranjan, dt, rajur

This patch adds TCAM reference counting
support for raw mac filters.

Signed-off-by: Raju Rangoju <rajur@chelsio.com>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h     | 16 +++++++++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c | 46 ++++++++++++++++++++++++++
 2 files changed, 62 insertions(+)

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__ */
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c
index ab8f1ade981a..87939638e8fc 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c
@@ -54,6 +54,52 @@ static int cxgb4_mps_ref_inc(struct adapter *adap, const u8 *mac_addr,
 	return ret;
 }
 
+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 ret = 0;
+
+	if (!cxgb4_mps_ref_dec(adap, idx))
+		ret = t4_free_raw_mac_filt(adap, viid, addr,
+					   mask, idx, lookup_type,
+					   port_id, sleep_ok);
+
+	return ret;
+}
+
+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)
+{
+	int ret;
+
+	ret = t4_alloc_raw_mac_filt(adap, viid, addr,
+				    mask, idx, lookup_type,
+				    port_id, sleep_ok);
+	if (ret < 0)
+		return ret;
+
+	if (cxgb4_mps_ref_inc(adap, addr, ret, mask)) {
+		ret = -ENOMEM;
+		t4_free_raw_mac_filt(adap, viid, addr,
+				     mask, idx, lookup_type,
+				     port_id, sleep_ok);
+	}
+
+	return ret;
+}
+
 int cxgb4_free_encap_mac_filt(struct adapter *adap, unsigned int viid,
 			      int idx, bool sleep_ok)
 {
-- 
2.12.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 net-next 3/4] cxgb4: Add MPS TCAM refcounting for cxgb4 change mac
  2019-06-24  8:50 [PATCH v2 net-next 0/4] cxgb4: Reference count MPS TCAM entries within a PF Raju Rangoju
  2019-06-24  8:50 ` [PATCH v2 net-next 1/4] cxgb4: Re-work the logic for mps refcounting Raju Rangoju
  2019-06-24  8:50 ` [PATCH v2 net-next 2/4] cxgb4: Add MPS TCAM refcounting for raw mac filters Raju Rangoju
@ 2019-06-24  8:50 ` Raju Rangoju
  2019-06-24  8:50 ` [PATCH v2 net-next 4/4] cxgb4: Add MPS refcounting for alloc/free mac filters Raju Rangoju
  2019-06-24 14:51 ` [PATCH v2 net-next 0/4] cxgb4: Reference count MPS TCAM entries within a PF David Miller
  4 siblings, 0 replies; 13+ messages in thread
From: Raju Rangoju @ 2019-06-24  8:50 UTC (permalink / raw)
  To: netdev, davem; +Cc: nirranjan, dt, rajur

This patch adds TCAM reference counting
support for cxgb4 change mac path

Signed-off-by: Raju Rangoju <rajur@chelsio.com>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h      |  7 +++++++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 14 +++++++-------
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c  | 15 +++++++++++++++
 3 files changed, 29 insertions(+), 7 deletions(-)

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__ */
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 4632827f05ba..1520e5294289 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -449,9 +449,9 @@ static int set_rxmode(struct net_device *dev, int mtu, bool sleep_ok)
  *	Addresses are programmed to hash region, if tcam runs out of entries.
  *
  */
-static int cxgb4_change_mac(struct port_info *pi, unsigned int viid,
-			    int *tcam_idx, const u8 *addr, bool persist,
-			    u8 *smt_idx)
+int cxgb4_change_mac(struct port_info *pi, unsigned int viid,
+		     int *tcam_idx, const u8 *addr, bool persist,
+		     u8 *smt_idx)
 {
 	struct adapter *adapter = pi->adapter;
 	struct hash_mac_addr *entry, *new_entry;
@@ -505,8 +505,8 @@ static int link_start(struct net_device *dev)
 	ret = t4_set_rxmode(pi->adapter, mb, pi->viid, dev->mtu, -1, -1, -1,
 			    !!(dev->features & NETIF_F_HW_VLAN_CTAG_RX), true);
 	if (ret == 0)
-		ret = cxgb4_change_mac(pi, pi->viid, &pi->xact_addr_filt,
-				       dev->dev_addr, true, &pi->smt_idx);
+		ret = cxgb4_update_mac_filt(pi, pi->viid, &pi->xact_addr_filt,
+					    dev->dev_addr, true, &pi->smt_idx);
 	if (ret == 0)
 		ret = t4_link_l1cfg(pi->adapter, mb, pi->tx_chan,
 				    &pi->link_cfg);
@@ -3020,8 +3020,8 @@ static int cxgb_set_mac_addr(struct net_device *dev, void *p)
 	if (!is_valid_ether_addr(addr->sa_data))
 		return -EADDRNOTAVAIL;
 
-	ret = cxgb4_change_mac(pi, pi->viid, &pi->xact_addr_filt,
-			       addr->sa_data, true, &pi->smt_idx);
+	ret = cxgb4_update_mac_filt(pi, pi->viid, &pi->xact_addr_filt,
+				    addr->sa_data, true, &pi->smt_idx);
 	if (ret < 0)
 		return ret;
 
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c
index 87939638e8fc..f9d2271c0706 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c
@@ -54,6 +54,21 @@ static int cxgb4_mps_ref_inc(struct adapter *adap, const u8 *mac_addr,
 	return ret;
 }
 
+int cxgb4_update_mac_filt(struct port_info *pi, unsigned int viid,
+			  int *tcam_idx, const u8 *addr,
+			  bool persistent, u8 *smt_idx)
+{
+	int ret;
+
+	ret = cxgb4_change_mac(pi, viid, tcam_idx,
+			       addr, persistent, smt_idx);
+	if (ret < 0)
+		return ret;
+
+	cxgb4_mps_ref_inc(pi->adapter, addr, *tcam_idx, NULL);
+	return ret;
+}
+
 int cxgb4_free_raw_mac_filt(struct adapter *adap,
 			    unsigned int viid,
 			    const u8 *addr,
-- 
2.12.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH v2 net-next 4/4] cxgb4: Add MPS refcounting for alloc/free mac filters
  2019-06-24  8:50 [PATCH v2 net-next 0/4] cxgb4: Reference count MPS TCAM entries within a PF Raju Rangoju
                   ` (2 preceding siblings ...)
  2019-06-24  8:50 ` [PATCH v2 net-next 3/4] cxgb4: Add MPS TCAM refcounting for cxgb4 change mac Raju Rangoju
@ 2019-06-24  8:50 ` Raju Rangoju
  2019-06-24 15:51   ` kbuild test robot
                     ` (3 more replies)
  2019-06-24 14:51 ` [PATCH v2 net-next 0/4] cxgb4: Reference count MPS TCAM entries within a PF David Miller
  4 siblings, 4 replies; 13+ messages in thread
From: Raju Rangoju @ 2019-06-24  8:50 UTC (permalink / raw)
  To: netdev, davem; +Cc: nirranjan, dt, rajur

This patch adds reference counting support for
alloc/free mac filters

Signed-off-by: Raju Rangoju <rajur@chelsio.com>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h      |  6 +++
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 12 +++--
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c  | 72 +++++++++++++++++++++++++
 3 files changed, 87 insertions(+), 3 deletions(-)

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,
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 1520e5294289..b08efc48d42f 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -366,13 +366,19 @@ static int cxgb4_mac_sync(struct net_device *netdev, const u8 *mac_addr)
 	int ret;
 	u64 mhash = 0;
 	u64 uhash = 0;
+	/* idx stores the index of allocated filters,
+	 * its size should be modified based on the number of
+	 * MAC addresses that we allocate filters for
+	 */
+
+	u16 idx[1] = {};
 	bool free = false;
 	bool ucast = is_unicast_ether_addr(mac_addr);
 	const u8 *maclist[1] = {mac_addr};
 	struct hash_mac_addr *new_entry;
 
-	ret = t4_alloc_mac_filt(adap, adap->mbox, pi->viid, free, 1, maclist,
-				NULL, ucast ? &uhash : &mhash, false);
+	ret = cxgb4_alloc_mac_filt(adap, pi->viid, free, 1, maclist,
+				   idx, ucast ? &uhash : &mhash, false);
 	if (ret < 0)
 		goto out;
 	/* if hash != 0, then add the addr to hash addr list
@@ -410,7 +416,7 @@ static int cxgb4_mac_unsync(struct net_device *netdev, const u8 *mac_addr)
 		}
 	}
 
-	ret = t4_free_mac_filt(adap, adap->mbox, pi->viid, 1, maclist, false);
+	ret = cxgb4_free_mac_filt(adap, pi->viid, 1, maclist, false);
 	return ret < 0 ? -EINVAL : 0;
 }
 
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c
index f9d2271c0706..f18388e4e95b 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c
@@ -3,6 +3,31 @@
 
 #include "cxgb4.h"
 
+static int cxgb4_mps_ref_dec_by_mac(struct adapter *adap,
+				    const u8 *addr, const u8 *mask)
+{
+	u8 bitmask[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+	struct mps_entries_ref *mps_entry, *tmp;
+	int ret = -EINVAL;
+
+	spin_lock_bh(&adap->mps_ref_lock);
+	list_for_each_entry_safe(mps_entry, tmp, &adap->mps_ref, list) {
+		if (ether_addr_equal(mps_entry->addr, addr) &&
+		    ether_addr_equal(mps_entry->mask, mask ? mask : bitmask)) {
+			if (!atomic_dec_and_test(&mps_entry->refcnt)) {
+				spin_unlock_bh(&adap->mps_ref_lock);
+				return -EBUSY;
+			}
+			list_del(&mps_entry->list);
+			kfree(mps_entry);
+			ret = 0;
+			break;
+		}
+	}
+	spin_unlock_bh(&adap->mps_ref_lock);
+	return ret;
+}
+
 static int cxgb4_mps_ref_dec(struct adapter *adap, u16 idx)
 {
 	struct mps_entries_ref *mps_entry, *tmp;
@@ -54,6 +79,53 @@ static int cxgb4_mps_ref_inc(struct adapter *adap, const u8 *mac_addr,
 	return ret;
 }
 
+int cxgb4_free_mac_filt(struct adapter *adap, unsigned int viid,
+			unsigned int naddr, const u8 **addr, bool sleep_ok)
+{
+	int ret, i;
+
+	for (i = 0; i < naddr; i++) {
+		if (!cxgb4_mps_ref_dec_by_mac(adap, addr[i], NULL)) {
+			ret = t4_free_mac_filt(adap, adap->mbox, viid,
+					       1, &addr[i], sleep_ok);
+			if (ret < 0)
+				return ret;
+		}
+	}
+
+	/* return number of filters freed */
+	return naddr;
+}
+
+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 ret, i;
+
+	ret = t4_alloc_mac_filt(adap, adap->mbox, viid, free,
+				naddr, addr, idx, hash, sleep_ok);
+	if (ret < 0)
+		return ret;
+
+	for (i = 0; i < naddr; i++) {
+		if (idx[i] != 0xffff) {
+			if (cxgb4_mps_ref_inc(adap, addr[i], idx[i], NULL)) {
+				ret = -ENOMEM;
+				goto error;
+			}
+		}
+	}
+
+	goto out;
+error:
+	cxgb4_free_mac_filt(adap, viid, naddr, addr, sleep_ok);
+
+out:
+	/* Returns a negative error number or the number of filters allocated */
+	return ret;
+}
+
 int cxgb4_update_mac_filt(struct port_info *pi, unsigned int viid,
 			  int *tcam_idx, const u8 *addr,
 			  bool persistent, u8 *smt_idx)
-- 
2.12.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 net-next 0/4] cxgb4: Reference count MPS TCAM entries within a PF
  2019-06-24  8:50 [PATCH v2 net-next 0/4] cxgb4: Reference count MPS TCAM entries within a PF Raju Rangoju
                   ` (3 preceding siblings ...)
  2019-06-24  8:50 ` [PATCH v2 net-next 4/4] cxgb4: Add MPS refcounting for alloc/free mac filters Raju Rangoju
@ 2019-06-24 14:51 ` David Miller
  2019-06-24 14:53   ` David Miller
  4 siblings, 1 reply; 13+ messages in thread
From: David Miller @ 2019-06-24 14:51 UTC (permalink / raw)
  To: rajur; +Cc: netdev, nirranjan, dt

From: Raju Rangoju <rajur@chelsio.com>
Date: Mon, 24 Jun 2019 14:20:33 +0530

> Firmware reference counts the MPS TCAM entries by PF and VF,
> but it does not do it for usage within a PF or VF. This patch
> adds the support to track MPS TCAM entries within a PF.
> 
> v1->v2:
>  Use refcount_t type instead of atomic_t for mps reference count

Series applied, thanks.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 net-next 0/4] cxgb4: Reference count MPS TCAM entries within a PF
  2019-06-24 14:51 ` [PATCH v2 net-next 0/4] cxgb4: Reference count MPS TCAM entries within a PF David Miller
@ 2019-06-24 14:53   ` David Miller
  2019-06-24 14:54     ` David Miller
  2019-06-24 17:06     ` Raju Rangoju
  0 siblings, 2 replies; 13+ messages in thread
From: David Miller @ 2019-06-24 14:53 UTC (permalink / raw)
  To: rajur; +Cc: netdev, nirranjan, dt

From: David Miller <davem@davemloft.net>
Date: Mon, 24 Jun 2019 07:51:32 -0700 (PDT)

> From: Raju Rangoju <rajur@chelsio.com>
> Date: Mon, 24 Jun 2019 14:20:33 +0530
> 
>> Firmware reference counts the MPS TCAM entries by PF and VF,
>> but it does not do it for usage within a PF or VF. This patch
>> adds the support to track MPS TCAM entries within a PF.
>> 
>> v1->v2:
>>  Use refcount_t type instead of atomic_t for mps reference count
> 
> Series applied, thanks.

Umm, REALLY?!?!?!

drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c: In function ‘cxgb4_mps_ref_dec_by_mac’:
drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c:17:29: error: passing argument 1 of ‘atomic_dec_and_test’ from incompatible pointer type [-Werror=incompatible-pointer-types]
    if (!atomic_dec_and_test(&mps_entry->refcnt)) {
                             ^~~~~~~~~~~~~~~~~~

You just changed it to a refcount_t and didn't try compiling the
result?

The whole point of refcount_t is that it uses a different set of
interfaces to manipulate the object and you have to therefore
update all the call sites properly.

Reverted...

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 net-next 0/4] cxgb4: Reference count MPS TCAM entries within a PF
  2019-06-24 14:53   ` David Miller
@ 2019-06-24 14:54     ` David Miller
  2019-06-24 17:06     ` Raju Rangoju
  1 sibling, 0 replies; 13+ messages in thread
From: David Miller @ 2019-06-24 14:54 UTC (permalink / raw)
  To: rajur; +Cc: netdev, nirranjan, dt

From: David Miller <davem@davemloft.net>
Date: Mon, 24 Jun 2019 07:53:23 -0700 (PDT)

> You just changed it to a refcount_t and didn't try compiling the
> result?

You also need to fix this, which I tried to take care of this time:

Applying: cxgb4: Re-work the logic for mps refcounting
.git/rebase-apply/patch:291: new blank line at EOF.
+

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 net-next 4/4] cxgb4: Add MPS refcounting for alloc/free mac filters
  2019-06-24  8:50 ` [PATCH v2 net-next 4/4] cxgb4: Add MPS refcounting for alloc/free mac filters Raju Rangoju
@ 2019-06-24 15:51   ` kbuild test robot
  2019-06-24 16:59   ` kbuild test robot
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 13+ messages in thread
From: kbuild test robot @ 2019-06-24 15:51 UTC (permalink / raw)
  To: Raju Rangoju; +Cc: kbuild-all, netdev, davem, nirranjan, dt, rajur

[-- Attachment #1: Type: text/plain, Size: 3127 bytes --]

Hi Raju,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Raju-Rangoju/cxgb4-Reference-count-MPS-TCAM-entries-within-a-PF/20190624-230630
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 7.4.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.4.0 make.cross ARCH=ia64 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c: In function 'cxgb4_mps_ref_dec_by_mac':
>> drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c:17:29: error: passing argument 1 of 'atomic_dec_and_test' from incompatible pointer type [-Werror=incompatible-pointer-types]
       if (!atomic_dec_and_test(&mps_entry->refcnt)) {
                                ^
   In file included from include/linux/atomic.h:74:0,
                    from arch/ia64/include/asm/processor.h:79,
                    from arch/ia64/include/asm/thread_info.h:12,
                    from include/linux/thread_info.h:38,
                    from include/asm-generic/preempt.h:5,
                    from ./arch/ia64/include/generated/asm/preempt.h:1,
                    from include/linux/preempt.h:78,
                    from include/linux/hardirq.h:5,
                    from include/linux/interrupt.h:11,
                    from drivers/net/ethernet/chelsio/cxgb4/cxgb4.h:42,
                    from drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c:4:
   include/linux/atomic-fallback.h:1031:1: note: expected 'atomic_t * {aka struct <anonymous> *}' but argument is of type 'refcount_t * {aka struct refcount_struct *}'
    atomic_dec_and_test(atomic_t *v)
    ^~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors

vim +/atomic_dec_and_test +17 drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c

     5	
     6	static int cxgb4_mps_ref_dec_by_mac(struct adapter *adap,
     7					    const u8 *addr, const u8 *mask)
     8	{
     9		u8 bitmask[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
    10		struct mps_entries_ref *mps_entry, *tmp;
    11		int ret = -EINVAL;
    12	
    13		spin_lock_bh(&adap->mps_ref_lock);
    14		list_for_each_entry_safe(mps_entry, tmp, &adap->mps_ref, list) {
    15			if (ether_addr_equal(mps_entry->addr, addr) &&
    16			    ether_addr_equal(mps_entry->mask, mask ? mask : bitmask)) {
  > 17				if (!atomic_dec_and_test(&mps_entry->refcnt)) {
    18					spin_unlock_bh(&adap->mps_ref_lock);
    19					return -EBUSY;
    20				}
    21				list_del(&mps_entry->list);
    22				kfree(mps_entry);
    23				ret = 0;
    24				break;
    25			}
    26		}
    27		spin_unlock_bh(&adap->mps_ref_lock);
    28		return ret;
    29	}
    30	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 54085 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 net-next 4/4] cxgb4: Add MPS refcounting for alloc/free mac filters
  2019-06-24  8:50 ` [PATCH v2 net-next 4/4] cxgb4: Add MPS refcounting for alloc/free mac filters Raju Rangoju
  2019-06-24 15:51   ` kbuild test robot
@ 2019-06-24 16:59   ` kbuild test robot
  2019-06-24 17:16   ` kbuild test robot
  2019-06-24 18:24   ` kbuild test robot
  3 siblings, 0 replies; 13+ messages in thread
From: kbuild test robot @ 2019-06-24 16:59 UTC (permalink / raw)
  To: Raju Rangoju; +Cc: kbuild-all, netdev, davem, nirranjan, dt, rajur

Hi Raju,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Raju-Rangoju/cxgb4-Reference-count-MPS-TCAM-entries-within-a-PF/20190624-230630
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.1-rc1-7-g2b96cd8-dirty
        make ARCH=x86_64 allmodconfig
        make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)

>> drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c:17:51: sparse: sparse: incorrect type in argument 1 (different base types) @@    expected struct atomic_t [usertype] *v @@    got ct atomic_t [usertype] *v @@
>> drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c:17:51: sparse:    expected struct atomic_t [usertype] *v
>> drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c:17:51: sparse:    got struct refcount_struct *

vim +17 drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c

     5	
     6	static int cxgb4_mps_ref_dec_by_mac(struct adapter *adap,
     7					    const u8 *addr, const u8 *mask)
     8	{
     9		u8 bitmask[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
    10		struct mps_entries_ref *mps_entry, *tmp;
    11		int ret = -EINVAL;
    12	
    13		spin_lock_bh(&adap->mps_ref_lock);
    14		list_for_each_entry_safe(mps_entry, tmp, &adap->mps_ref, list) {
    15			if (ether_addr_equal(mps_entry->addr, addr) &&
    16			    ether_addr_equal(mps_entry->mask, mask ? mask : bitmask)) {
  > 17				if (!atomic_dec_and_test(&mps_entry->refcnt)) {
    18					spin_unlock_bh(&adap->mps_ref_lock);
    19					return -EBUSY;
    20				}
    21				list_del(&mps_entry->list);
    22				kfree(mps_entry);
    23				ret = 0;
    24				break;
    25			}
    26		}
    27		spin_unlock_bh(&adap->mps_ref_lock);
    28		return ret;
    29	}
    30	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 net-next 0/4] cxgb4: Reference count MPS TCAM entries within a PF
  2019-06-24 14:53   ` David Miller
  2019-06-24 14:54     ` David Miller
@ 2019-06-24 17:06     ` Raju Rangoju
  1 sibling, 0 replies; 13+ messages in thread
From: Raju Rangoju @ 2019-06-24 17:06 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, nirranjan, dt

On Monday, June 06/24/19, 2019 at 07:53:23 -0700, David Miller wrote:
> From: David Miller <davem@davemloft.net>
> Date: Mon, 24 Jun 2019 07:51:32 -0700 (PDT)
> 
> > From: Raju Rangoju <rajur@chelsio.com>
> > Date: Mon, 24 Jun 2019 14:20:33 +0530
> > 
> >> Firmware reference counts the MPS TCAM entries by PF and VF,
> >> but it does not do it for usage within a PF or VF. This patch
> >> adds the support to track MPS TCAM entries within a PF.
> >> 
> >> v1->v2:
> >>  Use refcount_t type instead of atomic_t for mps reference count
> > 
> > Series applied, thanks.
> 
> Umm, REALLY?!?!?!
> 
> drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c: In function ‘cxgb4_mps_ref_dec_by_mac’:
> drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c:17:29: error: passing argument 1 of ‘atomic_dec_and_test’ from incompatible pointer type [-Werror=incompatible-pointer-types]
>     if (!atomic_dec_and_test(&mps_entry->refcnt)) {
>                              ^~~~~~~~~~~~~~~~~~
> 
> You just changed it to a refcount_t and didn't try compiling the
> result?
> 

No. I'm pretty sure that I have compiled and tested the changes. But, my bad
I had missed to '--amend' the last patch after 'git add'.

I'll send out next version.

> The whole point of refcount_t is that it uses a different set of
> interfaces to manipulate the object and you have to therefore
> update all the call sites properly.
> 
> Reverted...

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 net-next 4/4] cxgb4: Add MPS refcounting for alloc/free mac filters
  2019-06-24  8:50 ` [PATCH v2 net-next 4/4] cxgb4: Add MPS refcounting for alloc/free mac filters Raju Rangoju
  2019-06-24 15:51   ` kbuild test robot
  2019-06-24 16:59   ` kbuild test robot
@ 2019-06-24 17:16   ` kbuild test robot
  2019-06-24 18:24   ` kbuild test robot
  3 siblings, 0 replies; 13+ messages in thread
From: kbuild test robot @ 2019-06-24 17:16 UTC (permalink / raw)
  To: Raju Rangoju; +Cc: kbuild-all, netdev, davem, nirranjan, dt, rajur

[-- Attachment #1: Type: text/plain, Size: 2258 bytes --]

Hi Raju,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Raju-Rangoju/cxgb4-Reference-count-MPS-TCAM-entries-within-a-PF/20190624-230630
config: x86_64-rhel-7.2 (attached as .config)
compiler: clang version 9.0.0 (git://gitmirror/llvm_project fb2bd4a9398b35ee4f732ea0847d9c1226fc4cf3)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/net//ethernet/chelsio/cxgb4/cxgb4_mps.c:17:29: error: incompatible pointer types passing 'refcount_t *' (aka 'struct refcount_struct *') to parameter of type 'atomic_t *' [-Werror,-Wincompatible-pointer-types]
                           if (!atomic_dec_and_test(&mps_entry->refcnt)) {
                                                    ^~~~~~~~~~~~~~~~~~
   include/asm-generic/atomic-instrumented.h:745:31: note: passing argument to parameter 'v' here
   atomic_dec_and_test(atomic_t *v)
                                 ^
   1 error generated.

vim +17 drivers/net//ethernet/chelsio/cxgb4/cxgb4_mps.c

     5	
     6	static int cxgb4_mps_ref_dec_by_mac(struct adapter *adap,
     7					    const u8 *addr, const u8 *mask)
     8	{
     9		u8 bitmask[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
    10		struct mps_entries_ref *mps_entry, *tmp;
    11		int ret = -EINVAL;
    12	
    13		spin_lock_bh(&adap->mps_ref_lock);
    14		list_for_each_entry_safe(mps_entry, tmp, &adap->mps_ref, list) {
    15			if (ether_addr_equal(mps_entry->addr, addr) &&
    16			    ether_addr_equal(mps_entry->mask, mask ? mask : bitmask)) {
  > 17				if (!atomic_dec_and_test(&mps_entry->refcnt)) {
    18					spin_unlock_bh(&adap->mps_ref_lock);
    19					return -EBUSY;
    20				}
    21				list_del(&mps_entry->list);
    22				kfree(mps_entry);
    23				ret = 0;
    24				break;
    25			}
    26		}
    27		spin_unlock_bh(&adap->mps_ref_lock);
    28		return ret;
    29	}
    30	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 42604 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2 net-next 4/4] cxgb4: Add MPS refcounting for alloc/free mac filters
  2019-06-24  8:50 ` [PATCH v2 net-next 4/4] cxgb4: Add MPS refcounting for alloc/free mac filters Raju Rangoju
                     ` (2 preceding siblings ...)
  2019-06-24 17:16   ` kbuild test robot
@ 2019-06-24 18:24   ` kbuild test robot
  3 siblings, 0 replies; 13+ messages in thread
From: kbuild test robot @ 2019-06-24 18:24 UTC (permalink / raw)
  To: Raju Rangoju; +Cc: kbuild-all, netdev, davem, nirranjan, dt, rajur

[-- Attachment #1: Type: text/plain, Size: 2908 bytes --]

Hi Raju,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Raju-Rangoju/cxgb4-Reference-count-MPS-TCAM-entries-within-a-PF/20190624-230630
config: x86_64-randconfig-b0-06242344 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c: In function 'cxgb4_mps_ref_dec_by_mac':
>> drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c:17:29: warning: passing argument 1 of 'atomic_dec_and_test' from incompatible pointer type
       if (!atomic_dec_and_test(&mps_entry->refcnt)) {
                                ^
   In file included from arch/x86/include/asm/atomic.h:265:0,
                    from arch/x86/include/asm/msr.h:67,
                    from arch/x86/include/asm/processor.h:21,
                    from arch/x86/include/asm/cpufeature.h:5,
                    from arch/x86/include/asm/thread_info.h:53,
                    from include/linux/thread_info.h:38,
                    from arch/x86/include/asm/preempt.h:7,
                    from include/linux/preempt.h:78,
                    from include/linux/hardirq.h:5,
                    from include/linux/interrupt.h:11,
                    from drivers/net/ethernet/chelsio/cxgb4/cxgb4.h:42,
                    from drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c:4:
   include/asm-generic/atomic-instrumented.h:745:1: note: expected 'struct atomic_t *' but argument is of type 'struct refcount_t *'
    atomic_dec_and_test(atomic_t *v)
    ^

vim +/atomic_dec_and_test +17 drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c

     5	
     6	static int cxgb4_mps_ref_dec_by_mac(struct adapter *adap,
     7					    const u8 *addr, const u8 *mask)
     8	{
     9		u8 bitmask[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
    10		struct mps_entries_ref *mps_entry, *tmp;
    11		int ret = -EINVAL;
    12	
    13		spin_lock_bh(&adap->mps_ref_lock);
    14		list_for_each_entry_safe(mps_entry, tmp, &adap->mps_ref, list) {
    15			if (ether_addr_equal(mps_entry->addr, addr) &&
    16			    ether_addr_equal(mps_entry->mask, mask ? mask : bitmask)) {
  > 17				if (!atomic_dec_and_test(&mps_entry->refcnt)) {
    18					spin_unlock_bh(&adap->mps_ref_lock);
    19					return -EBUSY;
    20				}
    21				list_del(&mps_entry->list);
    22				kfree(mps_entry);
    23				ret = 0;
    24				break;
    25			}
    26		}
    27		spin_unlock_bh(&adap->mps_ref_lock);
    28		return ret;
    29	}
    30	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 35462 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-06-24 18:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-24  8:50 [PATCH v2 net-next 0/4] cxgb4: Reference count MPS TCAM entries within a PF Raju Rangoju
2019-06-24  8:50 ` [PATCH v2 net-next 1/4] cxgb4: Re-work the logic for mps refcounting Raju Rangoju
2019-06-24  8:50 ` [PATCH v2 net-next 2/4] cxgb4: Add MPS TCAM refcounting for raw mac filters Raju Rangoju
2019-06-24  8:50 ` [PATCH v2 net-next 3/4] cxgb4: Add MPS TCAM refcounting for cxgb4 change mac Raju Rangoju
2019-06-24  8:50 ` [PATCH v2 net-next 4/4] cxgb4: Add MPS refcounting for alloc/free mac filters Raju Rangoju
2019-06-24 15:51   ` kbuild test robot
2019-06-24 16:59   ` kbuild test robot
2019-06-24 17:16   ` kbuild test robot
2019-06-24 18:24   ` kbuild test robot
2019-06-24 14:51 ` [PATCH v2 net-next 0/4] cxgb4: Reference count MPS TCAM entries within a PF David Miller
2019-06-24 14:53   ` David Miller
2019-06-24 14:54     ` David Miller
2019-06-24 17:06     ` Raju Rangoju

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).