git: a8076e0afdf4 - stable/13 - cxgbe(4): Add a driver ioctl to set the filter mask.

Navdeep Parhar np at FreeBSD.org
Sun May 16 02:53:52 UTC 2021


The branch stable/13 has been updated by np:

URL: https://cgit.FreeBSD.org/src/commit/?id=a8076e0afdf4e0af676a195708b20670ef4cb61a

commit a8076e0afdf4e0af676a195708b20670ef4cb61a
Author:     Navdeep Parhar <np at FreeBSD.org>
AuthorDate: 2021-02-19 21:47:18 +0000
Commit:     Navdeep Parhar <np at FreeBSD.org>
CommitDate: 2021-05-16 02:53:07 +0000

    cxgbe(4): Add a driver ioctl to set the filter mask.
    
    Allow the filter mask (aka the hashfilter mode when hashfilters are
    in use) to be set any time it is safe to do so.  The requested mask
    must be a subset of the filter mode already.  The driver will not change
    the mode or ingress config just to support a new mask.
    
    Sponsored by:   Chelsio Communications
    
    (cherry picked from commit c91dda5ad923f24ef2e538b8dc180fa98598b4db)
---
 sys/dev/cxgbe/adapter.h   |  1 +
 sys/dev/cxgbe/t4_filter.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 sys/dev/cxgbe/t4_ioctl.h  |  2 ++
 sys/dev/cxgbe/t4_main.c   |  3 +++
 4 files changed, 48 insertions(+)

diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h
index 12641cb2e628..0b7ceb147708 100644
--- a/sys/dev/cxgbe/adapter.h
+++ b/sys/dev/cxgbe/adapter.h
@@ -1345,6 +1345,7 @@ void cxgbe_ratelimit_query(struct ifnet *, struct if_ratelimit_query_results *);
 /* t4_filter.c */
 int get_filter_mode(struct adapter *, uint32_t *);
 int set_filter_mode(struct adapter *, uint32_t);
+int set_filter_mask(struct adapter *, uint32_t);
 int get_filter(struct adapter *, struct t4_filter *);
 int set_filter(struct adapter *, struct t4_filter *);
 int del_filter(struct adapter *, struct t4_filter *);
diff --git a/sys/dev/cxgbe/t4_filter.c b/sys/dev/cxgbe/t4_filter.c
index 1e0269fcd5c0..3afab0d1d6b9 100644
--- a/sys/dev/cxgbe/t4_filter.c
+++ b/sys/dev/cxgbe/t4_filter.c
@@ -543,6 +543,48 @@ done:
 	return (rc);
 }
 
+int
+set_filter_mask(struct adapter *sc, uint32_t mode)
+{
+	struct tp_params *tp = &sc->params.tp;
+	int rc, iconf;
+	uint16_t fmask;
+
+	iconf = mode_to_iconf(mode);
+	fmask = mode_to_fconf(mode);
+	if ((iconf == -1 || iconf == tp->vnic_mode) && fmask == tp->filter_mask)
+		return (0);	/* Nothing to do */
+
+	/*
+	 * We aren't going to change the global filter mode or VNIC mode here.
+	 * The given filter mask must conform to them.
+	 */
+	if ((fmask | tp->filter_mode) != tp->filter_mode)
+		return (EINVAL);
+	if (iconf != -1 && iconf != tp->vnic_mode)
+		return (EINVAL);
+
+	rc = begin_synchronized_op(sc, NULL, SLEEP_OK | INTR_OK, "t4sethfm");
+	if (rc)
+		return (rc);
+
+	if (sc->tids.tids_in_use > 0) {		/* TOE or hashfilters active */
+		rc = EBUSY;
+		goto done;
+	}
+
+#ifdef TCP_OFFLOAD
+	if (uld_active(sc, ULD_TOM)) {
+		rc = EBUSY;
+		goto done;
+	}
+#endif
+	rc = -t4_set_filter_cfg(sc, -1, fmask, -1);
+done:
+	end_synchronized_op(sc, 0);
+	return (rc);
+}
+
 static inline uint64_t
 get_filter_hits(struct adapter *sc, uint32_t tid)
 {
diff --git a/sys/dev/cxgbe/t4_ioctl.h b/sys/dev/cxgbe/t4_ioctl.h
index 4f0a71683ef0..ff2c5ef80a14 100644
--- a/sys/dev/cxgbe/t4_ioctl.h
+++ b/sys/dev/cxgbe/t4_ioctl.h
@@ -63,6 +63,7 @@ enum {
 	T4_LOAD_BOOT,			/* flash boot rom */
 	T4_LOAD_BOOTCFG,		/* flash bootcfg */
 	T4_CUDBG_DUMP,			/* debug dump of chip state */
+	T4_SET_FILTER_MASK,		/* set filter mask (hashfilter mode) */
 };
 
 struct t4_reg {
@@ -429,4 +430,5 @@ struct t4_offload_policy {
 #define CHELSIO_T4_LOAD_BOOTCFG	_IOW('f', T4_LOAD_BOOTCFG, struct t4_data)
 #define CHELSIO_T4_CUDBG_DUMP	_IOWR('f', T4_CUDBG_DUMP, struct t4_cudbg_dump)
 #define CHELSIO_T4_SET_OFLD_POLICY _IOW('f', T4_SET_OFLD_POLICY, struct t4_offload_policy)
+#define CHELSIO_T4_SET_FILTER_MASK _IOW('f', T4_SET_FILTER_MASK, uint32_t)
 #endif
diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c
index d25e83922d54..68fe25a2f62e 100644
--- a/sys/dev/cxgbe/t4_main.c
+++ b/sys/dev/cxgbe/t4_main.c
@@ -10968,6 +10968,9 @@ t4_ioctl(struct cdev *dev, unsigned long cmd, caddr_t data, int fflag,
 	case CHELSIO_T4_SET_FILTER_MODE:
 		rc = set_filter_mode(sc, *(uint32_t *)data);
 		break;
+	case CHELSIO_T4_SET_FILTER_MASK:
+		rc = set_filter_mask(sc, *(uint32_t *)data);
+		break;
 	case CHELSIO_T4_GET_FILTER:
 		rc = get_filter(sc, (struct t4_filter *)data);
 		break;


More information about the dev-commits-src-all mailing list