From: Andrew Lunn <andrew@lunn.ch>
To: Vivien Didelot <vivien.didelot@gmail.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net, f.fainelli@gmail.com
Subject: Re: [PATCH net-next 3/3] net: dsa: mv88e6xxx: add RXNFC support
Date: Sat, 7 Sep 2019 22:32:56 +0200 [thread overview]
Message-ID: <20190907203256.GA18741@lunn.ch> (raw)
In-Reply-To: <20190907200049.25273-4-vivien.didelot@gmail.com>
> +static int mv88e6xxx_policy_insert(struct mv88e6xxx_chip *chip, int port,
> + struct ethtool_rx_flow_spec *fs)
> +{
> + struct ethhdr *mac_entry = &fs->h_u.ether_spec;
> + struct ethhdr *mac_mask = &fs->m_u.ether_spec;
> + enum mv88e6xxx_policy_mapping mapping;
> + enum mv88e6xxx_policy_action action;
> + struct mv88e6xxx_policy *policy;
> + u16 vid = 0;
> + u8 *addr;
> + int err;
> + int id;
> +
> + if (fs->location != RX_CLS_LOC_ANY)
> + return -EINVAL;
> +
> + if (fs->ring_cookie == RX_CLS_FLOW_DISC)
> + action = MV88E6XXX_POLICY_ACTION_DISCARD;
> + else
> + return -EOPNOTSUPP;
> +
> + switch (fs->flow_type & ~FLOW_EXT) {
> + case ETHER_FLOW:
> + if (!is_zero_ether_addr(mac_mask->h_dest) &&
> + is_zero_ether_addr(mac_mask->h_source)) {
> + mapping = MV88E6XXX_POLICY_MAPPING_DA;
> + addr = mac_entry->h_dest;
> + } else if (is_zero_ether_addr(mac_mask->h_dest) &&
> + !is_zero_ether_addr(mac_mask->h_source)) {
> + mapping = MV88E6XXX_POLICY_MAPPING_SA;
> + addr = mac_entry->h_source;
> + } else {
> + /* Cannot support DA and SA mapping in the same rule */
> + return -EOPNOTSUPP;
> + }
> + break;
> + default:
> + return -EOPNOTSUPP;
> + }
> +
> + if ((fs->flow_type & FLOW_EXT) && fs->m_ext.vlan_tci) {
> + if (fs->m_ext.vlan_tci != 0xffff)
> + return -EOPNOTSUPP;
> + vid = be16_to_cpu(fs->h_ext.vlan_tci) & VLAN_VID_MASK;
> + }
> +
> + idr_for_each_entry(&chip->policies, policy, id) {
> + if (policy->port == port && policy->mapping == mapping &&
> + policy->action == action && policy->vid == vid &&
> + ether_addr_equal(policy->addr, addr))
> + return -EEXIST;
> + }
> +
> + policy = devm_kzalloc(chip->dev, sizeof(*policy), GFP_KERNEL);
> + if (!policy)
> + return -ENOMEM;
Hi Vivien
I think this might be the first time we have done dynamic memory
allocation in the mv88e6xxx driver. It might even be a first for a DSA
driver?
I'm not saying it is wrong, but maybe we should discuss it.
I assume you are doing this because the ATU entry itself is not
sufficient?
How much memory is involved here, worst case? I assume one struct
mv88e6xxx_policy per ATU entry? Which you think is too much to
allocate as part of chip? I guess most users will never use this
feature, so for most users it would be wasted memory. So i do see the
point for dynamically allocating it.
Thanks
Andrew
next prev parent reply other threads:[~2019-09-07 20:33 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-07 20:00 [PATCH net-next 0/3] net: dsa: mv88e6xxx: add PCL support Vivien Didelot
2019-09-07 20:00 ` [PATCH net-next 1/3] net: dsa: mv88e6xxx: complete ATU state definitions Vivien Didelot
2019-09-07 20:33 ` Andrew Lunn
2019-09-07 20:00 ` [PATCH net-next 2/3] net: dsa: mv88e6xxx: introduce .port_set_policy Vivien Didelot
2019-09-07 20:33 ` Andrew Lunn
2019-09-07 23:54 ` Marek Behun
2019-09-07 20:00 ` [PATCH net-next 3/3] net: dsa: mv88e6xxx: add RXNFC support Vivien Didelot
2019-09-07 20:32 ` Andrew Lunn [this message]
2019-09-07 21:25 ` Vivien Didelot
2019-09-08 8:55 ` Andrew Lunn
2019-09-08 2:48 ` Florian Fainelli
2019-09-10 15:53 ` [PATCH net-next 0/3] net: dsa: mv88e6xxx: add PCL support 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=20190907203256.GA18741@lunn.ch \
--to=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=vivien.didelot@gmail.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;
as well as URLs for NNTP newsgroup(s).