From: Or Gerlitz <ogerlitz@mellanox.com>
To: Ben Hutchings <bhutchings@solarflare.com>
Cc: <davem@davemloft.net>, <roland@kernel.org>,
Yevgeny Petrilin <yevgenyp@mellanox.com>,
Oren Duer <oren@mellanox.com>, <netdev@vger.kernel.org>,
Hadar Hen Zion <hadarh@mellanox.co.il>,
Amir Vadai <amirv@mellanox.co.il>
Subject: Re: [PATCH net-next 09/10] net/mlx4_en: Manage flow steering rules with ethtool
Date: Mon, 2 Jul 2012 15:57:49 +0300 [thread overview]
Message-ID: <4FF19ACD.6040602@mellanox.com> (raw)
In-Reply-To: <1341158452.4852.107.camel@deadeye.wl.decadent.org.uk>
On 7/1/2012 7:00 PM, Ben Hutchings wrote:
[...]
Hi Ben,
Thanks for the detailed feedback, see below some responses
> + l4_mask = &cmd->fs.m_u.tcp_ip4_spec;
> + /* don't allow mask which isn't all 0 or 1 */
> + if (not_all_zeros_or_all_ones(l4_mask->ip4src, __be32) ||
> + not_all_zeros_or_all_ones(l4_mask->ip4dst, __be32) ||
> + not_all_zeros_or_all_ones(l4_mask->psrc, __be16) ||
> + not_all_zeros_or_all_ones(l4_mask->pdst, __be16))
> + return -EOPNOTSUPP;
>
> Again, here and in many further instances, the error code should be EINVAL.
OK, will fix to use EINVAL instead of EOPNOTSUPP here and else-where needed.
> +
> +static void add_ip_rule(struct mlx4_en_priv *priv,
> + struct ethtool_rxnfc *cmd,
> + struct list_head *list_h)
> +{
> + struct mlx4_spec_list *spec_l3;
> +
> + spec_l3 = kzalloc(sizeof *spec_l3, GFP_KERNEL);
> + if (!spec_l3) {
> + en_err(priv, "Fail to alloc ethtool rule.\n");
> + return;
> + }
>
> This should return an error code as well - logging is not a substitue.
OK, will do.
>
>
>> + spec_l3->id = MLX4_NET_TRANS_RULE_ID_IPV4;
>> + spec_l3->ipv4.src_ip = cmd->fs.h_u.usr_ip4_spec.ip4src;
>> + if (spec_l3->ipv4.src_ip)
>> + spec_l3->ipv4.src_ip_msk = EN_ETHTOOL_WORD_MASK;
>> + spec_l3->ipv4.dst_ip = cmd->fs.h_u.usr_ip4_spec.ip4dst;
>> + if (spec_l3->ipv4.dst_ip)
>> + spec_l3->ipv4.dst_ip_msk = EN_ETHTOOL_WORD_MASK;
>
> The conditions should be using the mask (cmd->fs.m_u) not the value.
I'd like to clarify things here a bit - the way the code is written, is to
1st make sure that we can deal with the mask provided by the user in the
ethtool
command, e.g its all zeroes or all ones (leaving a side for a minute the
other
discussion on how would be best to impl. that check...) - this check is
done
in mlx4_en_validate_flow
2nd initialize mlx4 flow spec which is all empty - see calls to kzalloc
spec_l2/l3/l4
3rd import the non-zero values (not masks) from the ethtool command into
the mlx4
flow specs, with FULL mask
Under this logic, we can use the values and not the masks, isn't that?
>
>
>> +static void add_tcp_udp_rule(struct mlx4_en_priv *priv,
>> + struct ethtool_rxnfc *cmd,
>> + struct list_head *list_h, int proto)
>> +{
>> + struct mlx4_spec_list *spec_l3;
>> + struct mlx4_spec_list *spec_l4;
>> +
>> + spec_l3 = kzalloc(sizeof *spec_l3, GFP_KERNEL);
>> + spec_l4 = kzalloc(sizeof *spec_l4, GFP_KERNEL);
>> + if (!spec_l4 || !spec_l3) {
>> + en_err(priv, "Fail to alloc ethtool rule.\n");
>
> If one of them was successfully allocated, it will now be leaked.
THANKS, will fix.
>> +static int mlx4_en_ethtool_to_net_trans_rule(struct net_device *dev,
>> + struct ethtool_rxnfc *cmd,
>> + struct list_head *rule_list_h)
>> +{
>> + int err;
>> + u64 mac;
>> + __be64 be_mac;
>> + struct ethhdr *eth_spec;
>> + struct mlx4_en_priv *priv = netdev_priv(dev);
>> + struct mlx4_spec_list *spec_l2;
>> + __be64 mac_msk = cpu_to_be64(EN_ETHTOOL_MAC_MASK << 16);
>> +
>> + err = mlx4_en_validate_flow(dev, cmd);
>> + if (err)
>> + return err;
>> +
>> + spec_l2 = kzalloc(sizeof *spec_l2, GFP_KERNEL);
>> + if (!spec_l2)
>> + return -ENOMEM;
>> +
>> + mac = priv->mac & EN_ETHTOOL_MAC_MASK;
>> + be_mac = cpu_to_be64(mac << 16);
>> +
>> + spec_l2->id = MLX4_NET_TRANS_RULE_ID_ETH;
>> + memcpy(spec_l2->eth.dst_mac_msk, &mac_msk, ETH_ALEN);
>> + if ((cmd->fs.flow_type & ~FLOW_EXT) != ETHER_FLOW)
>> + memcpy(spec_l2->eth.dst_mac, &be_mac, ETH_ALEN);
>
> Does the hardware require filtering by MAC address and not only by layer 3/4 addresses?
YES
>
>
>> + if ((cmd->fs.flow_type & FLOW_EXT) && cmd->fs.m_ext.vlan_tci) {
>> + spec_l2->eth.vlan_id = cmd->fs.h_ext.vlan_tci;
>> + spec_l2->eth.vlan_id_msk = cpu_to_be16(0xfff);
>
> This doesn't match mlx4_en_validate_flow(); you are replacing a mask of
> 0xffff with 0xfff.
I need to check how exactly this should be done here, vlan ID is only 12
bits in size, so this is
probably the source for the 0xfff vs 0xffff
>
>
>> + switch (cmd->fs.flow_type & ~FLOW_EXT) {
>> + case ETHER_FLOW:
>> + eth_spec = &cmd->fs.h_u.ether_spec;
>> + memcpy(&spec_l2->eth.dst_mac, eth_spec->h_dest, ETH_ALEN);
>> + spec_l2->eth.ether_type = eth_spec->h_proto;
>> + if (eth_spec->h_proto)
>> + spec_l2->eth.ether_type_enable = 1;
>> + break;
>> + case IP_USER_FLOW:
>> + add_ip_rule(priv, cmd, rule_list_h);
>> + break;
>> + case TCP_V4_FLOW:
>> + add_tcp_udp_rule(priv, cmd, rule_list_h, TCP_V4_FLOW);
>> + break;
>> + case UDP_V4_FLOW:
>> + add_tcp_udp_rule(priv, cmd, rule_list_h, UDP_V4_FLOW);
>> + break;
>
> All those functions need to be able to return errors.
OK
next prev parent reply other threads:[~2012-07-02 12:58 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-01 9:43 [PATCH net-next 00/10] net/mlx4: Add flow-steering support Or Gerlitz
2012-07-01 9:43 ` [PATCH net-next 01/10] net/mlx4_core: Change resource tracking mechanism to use red-black tree Or Gerlitz
2012-07-01 10:17 ` David Miller
2012-07-01 9:43 ` [PATCH net-next 02/10] net/mlx4_core: Change resource tracking ID to be 64 bit Or Gerlitz
2012-07-01 9:43 ` [PATCH net-next 03/10] net/mlx4_en: Re-design multicast attachments flow Or Gerlitz
2012-07-01 10:32 ` David Miller
2012-07-01 9:43 ` [PATCH net-next 04/10] net/mlx4: Set steering mode according to device capabilities Or Gerlitz
2012-07-01 10:20 ` David Miller
2012-07-01 9:43 ` [PATCH net-next 05/10] net/mlx4_core: Add firmware commands to support device managed flow steering Or Gerlitz
2012-07-01 9:43 ` [PATCH net-next 06/10] {NET,IB}/mlx4: Add device managed flow steering firmware API Or Gerlitz
2012-07-01 10:30 ` David Miller
2012-07-01 12:29 ` Or Gerlitz
2012-07-01 21:42 ` David Miller
2012-07-02 7:55 ` Or Gerlitz
2012-07-02 8:14 ` Roland Dreier
2012-07-02 8:28 ` Or Gerlitz
2012-07-02 8:36 ` David Miller
2012-07-02 13:00 ` Or Gerlitz
2012-07-02 8:34 ` David Miller
2012-07-02 18:07 ` Ben Hutchings
2012-07-03 0:15 ` David Miller
2012-07-03 1:04 ` David Miller
2012-07-03 11:10 ` Or Gerlitz
2012-07-01 9:43 ` [PATCH net-next 07/10] net/mlx4_core: Add resource tracking for device managed flow steering rules Or Gerlitz
2012-07-01 10:22 ` David Miller
2012-07-01 9:43 ` [PATCH net-next 08/10] net/mlx4: Implement promiscuous mode with device managed flow-steering Or Gerlitz
2012-07-01 9:43 ` [PATCH net-next 09/10] net/mlx4_en: Manage flow steering rules with ethtool Or Gerlitz
2012-07-01 10:23 ` David Miller
2012-07-01 16:00 ` Ben Hutchings
2012-07-01 16:38 ` Joe Perches
2012-07-01 17:31 ` Joe Perches
2012-07-01 18:48 ` Andreas Schwab
2012-07-01 19:52 ` Joe Perches
2012-07-02 10:19 ` David Laight
2012-07-02 11:35 ` Andreas Schwab
2012-07-02 12:15 ` David Laight
2012-07-03 8:14 ` Or Gerlitz
2012-07-02 12:57 ` Or Gerlitz [this message]
2012-07-03 1:47 ` Ben Hutchings
2012-07-03 8:56 ` Or Gerlitz
2012-07-03 8:58 ` Or Gerlitz
2012-07-02 13:32 ` Or Gerlitz
2012-07-03 1:50 ` Ben Hutchings
2012-07-03 9:00 ` Or Gerlitz
2012-07-01 9:43 ` [PATCH net-next 10/10] net/mlx4_en: Add support for drop action through ethtool Or Gerlitz
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=4FF19ACD.6040602@mellanox.com \
--to=ogerlitz@mellanox.com \
--cc=amirv@mellanox.co.il \
--cc=bhutchings@solarflare.com \
--cc=davem@davemloft.net \
--cc=hadarh@mellanox.co.il \
--cc=netdev@vger.kernel.org \
--cc=oren@mellanox.com \
--cc=roland@kernel.org \
--cc=yevgenyp@mellanox.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.