From: Jiri Pirko <jiri@resnulli.us>
To: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net,
hariprasad@chelsio.com, leedom@chelsio.com,
nirranjan@chelsio.com, indranil@chelsio.com
Subject: Re: [PATCH net-next 2/7] cxgb4: add common api support for configuring filters
Date: Mon, 12 Sep 2016 10:57:16 +0200 [thread overview]
Message-ID: <20160912085716.GG2021@nanopsycho> (raw)
In-Reply-To: <05ef6c530086d3df5b8f4128141e3c12d3812105.1473667613.git.rahul.lakkireddy@chelsio.com>
Mon, Sep 12, 2016 at 10:12:35AM CEST, rahul.lakkireddy@chelsio.com wrote:
>Enable filters for non-offload configuration and add common api support
>for setting and deleting filters in LE-TCAM region of the hardware.
>
>IPv4 filters occupy one slot. IPv6 filters occupy 4 slots and must
>be on a 4-slot boundary. IPv4 filters can not occupy a slot belonging
>to IPv6 and the vice-versa is also true.
>
>Filters are set and deleted asynchronously. Use completion to wait
>for reply from firmware in order to allow for synchronization if needed.
>
>Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
>Signed-off-by: Hariprasad Shenai <hariprasad@chelsio.com>
>---
> drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 3 +
> drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c | 424 +++++++++++++++++++++-
> drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.h | 1 +
> drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 33 +-
> drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h | 23 +-
> 5 files changed, 453 insertions(+), 31 deletions(-)
>
>diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
>index 053976f..fbd593a 100644
>--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
>+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
>@@ -1055,7 +1055,10 @@ struct filter_entry {
>
> u32 pending:1; /* filter action is pending firmware reply */
> u32 smtidx:8; /* Source MAC Table index for smac */
>+ struct filter_ctx *ctx; /* Caller's completion hook */
> struct l2t_entry *l2t; /* Layer Two Table entry for dmac */
>+ struct net_device *dev; /* Associated net device */
>+ u32 tid; /* This will store the actual tid */
>
> /* The filter itself. Most of this is a straight copy of information
> * provided by the extended ioctl(). Some fields are translated to
>diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
>index 2e86902..490bd94 100644
>--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
>+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
>@@ -33,10 +33,138 @@
> */
>
> #include "cxgb4.h"
>+#include "t4_regs.h"
> #include "l2t.h"
> #include "t4fw_api.h"
> #include "cxgb4_filter.h"
>
>+/* Validate filter spec against configuration done on the card.
>+ */
>+static int validate_filter(struct net_device *dev,
>+ struct ch_filter_specification *fs)
>+{
>+ struct adapter *adapter = netdev2adap(dev);
>+ u32 fconf, iconf;
>+
>+ /* Check for unconfigured fields being used. */
>+ fconf = adapter->params.tp.vlan_pri_map;
>+ iconf = adapter->params.tp.ingress_config;
>+
>+ #define S(_field) \
>+ (fs->val._field || fs->mask._field)
>+ #define U(_mask, _field) \
>+ (!(fconf & (_mask)) && S(_field))
Wow, this is really odd. Please replace these mysterious "S" and "U"
with some properly named static helper function.
>+
>+ if (U(FCOE_F, fcoe) || U(PORT_F, iport) || U(TOS_F, tos) ||
>+ U(ETHERTYPE_F, ethtype) || U(MACMATCH_F, macidx) ||
>+ U(MPSHITTYPE_F, matchtype) || U(FRAGMENTATION_F, frag) ||
>+ U(PROTOCOL_F, proto) ||
>+ U(VNIC_ID_F, pfvf_vld) ||
>+ U(VNIC_ID_F, ovlan_vld) ||
>+ U(VLAN_F, ivlan_vld))
>+ return -EOPNOTSUPP;
>+
>+ /* T4 inconveniently uses the same FT_VNIC_ID_W bits for both the Outer
>+ * VLAN Tag and PF/VF/VFvld fields based on VNIC_F being set
>+ * in TP_INGRESS_CONFIG. Hense the somewhat crazy checks
>+ * below. Additionally, since the T4 firmware interface also
>+ * carries that overlap, we need to translate any PF/VF
>+ * specification into that internal format below.
>+ */
>+ if (S(pfvf_vld) && S(ovlan_vld))
>+ return -EOPNOTSUPP;
>+ if ((S(pfvf_vld) && !(iconf & VNIC_F)) ||
>+ (S(ovlan_vld) && (iconf & VNIC_F)))
>+ return -EOPNOTSUPP;
>+ if (fs->val.pf > 0x7 || fs->val.vf > 0x7f)
>+ return -ERANGE;
>+ fs->mask.pf &= 0x7;
>+ fs->mask.vf &= 0x7f;
>+
>+ #undef S
>+ #undef U
>+
next prev parent reply other threads:[~2016-09-12 8:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-12 8:12 [PATCH net-next 0/7] cxgb4: add support for offloading TC u32 filters Rahul Lakkireddy
2016-09-12 8:12 ` [PATCH net-next 1/7] cxgb4: move common filter code to separate file Rahul Lakkireddy
2016-09-12 8:12 ` [PATCH net-next 2/7] cxgb4: add common api support for configuring filters Rahul Lakkireddy
2016-09-12 8:57 ` Jiri Pirko [this message]
2016-09-12 8:12 ` [PATCH net-next 3/7] cxgb4: add debugfs support to dump filter debug logs Rahul Lakkireddy
2016-09-12 8:36 ` Jiri Pirko
2016-09-12 8:12 ` [PATCH net-next 4/7] cxgb4: add parser to translate u32 filters to internal spec Rahul Lakkireddy
2016-09-12 8:12 ` [PATCH net-next 5/7] cxgb4: add support for setting u32 filters Rahul Lakkireddy
2016-09-12 8:40 ` Jiri Pirko
2016-09-12 8:12 ` [PATCH net-next 6/7] cxgb4: add support for deleting " Rahul Lakkireddy
2016-09-12 8:47 ` Jiri Pirko
2016-09-12 8:12 ` [PATCH net-next 7/7] cxgb4: add support for drop and redirect actions Rahul Lakkireddy
2016-09-12 8:52 ` Jiri Pirko
2016-09-12 15:17 ` John Fastabend
2016-09-13 9:07 ` [PATCH net-next 0/7] cxgb4: add support for offloading TC u32 filters Rahul Lakkireddy
2016-09-13 16:12 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160912085716.GG2021@nanopsycho \
--to=jiri@resnulli.us \
--cc=davem@davemloft.net \
--cc=hariprasad@chelsio.com \
--cc=indranil@chelsio.com \
--cc=leedom@chelsio.com \
--cc=netdev@vger.kernel.org \
--cc=nirranjan@chelsio.com \
--cc=rahul.lakkireddy@chelsio.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox