| Submitter | Amir Vadai |
|---|---|
| Date | Dec. 11, 2012, 12:03 p.m. |
| Message ID | <1355227436-18383-3-git-send-email-amirv@mellanox.com> |
| Download | mbox | patch |
| Permalink | /patch/205190/ |
| State | Changes Requested |
| Delegated to: | David Miller |
| Headers | show |
Comments
On 12/11/2012 07:03 AM, Amir Vadai wrote: > --- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c > +++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c > @@ -619,7 +619,13 @@ static int mlx4_en_validate_flow(struct net_device *dev, > if (cmd->fs.location >= MAX_NUM_OF_FS_RULES) > return -EINVAL; > > - switch (cmd->fs.flow_type & ~FLOW_EXT) { > + if (cmd->fs.flow_type & FLOW_MAC_EXT) { > + /* dest mac mask must be ff:ff:ff:ff:ff:ff */ > + if (memcmp(cmd->fs.m_ext.h_dest, &full_mac, ETH_ALEN)) > + return -EINVAL; > + } etherdevice.h has is_broadcast_ether_addr() and is_zero_ether_addr() if you want to get rid of full_mac and zero_mac in this function. -Brian -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 11/12/2012 17:38, Brian Haley wrote: > On 12/11/2012 07:03 AM, Amir Vadai wrote: >> --- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c >> +++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c >> @@ -619,7 +619,13 @@ static int mlx4_en_validate_flow(struct net_device *dev, >> if (cmd->fs.location >= MAX_NUM_OF_FS_RULES) >> return -EINVAL; >> >> - switch (cmd->fs.flow_type & ~FLOW_EXT) { >> + if (cmd->fs.flow_type & FLOW_MAC_EXT) { >> + /* dest mac mask must be ff:ff:ff:ff:ff:ff */ >> + if (memcmp(cmd->fs.m_ext.h_dest, &full_mac, ETH_ALEN)) >> + return -EINVAL; >> + } > > etherdevice.h has is_broadcast_ether_addr() and is_zero_ether_addr() if you want > to get rid of full_mac and zero_mac in this function. > > -Brian > Right, will send a V1 with this fix. Amir. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Patch
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c index 4aaa7c3..87a87a7 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c @@ -619,7 +619,13 @@ static int mlx4_en_validate_flow(struct net_device *dev, if (cmd->fs.location >= MAX_NUM_OF_FS_RULES) return -EINVAL; - switch (cmd->fs.flow_type & ~FLOW_EXT) { + if (cmd->fs.flow_type & FLOW_MAC_EXT) { + /* dest mac mask must be ff:ff:ff:ff:ff:ff */ + if (memcmp(cmd->fs.m_ext.h_dest, &full_mac, ETH_ALEN)) + return -EINVAL; + } + + switch (cmd->fs.flow_type & ~(FLOW_EXT | FLOW_MAC_EXT)) { case TCP_V4_FLOW: case UDP_V4_FLOW: if (cmd->fs.m_u.tcp_ip4_spec.tos) @@ -747,7 +753,6 @@ static int mlx4_en_ethtool_to_net_trans_rule(struct net_device *dev, 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); @@ -762,12 +767,16 @@ static int mlx4_en_ethtool_to_net_trans_rule(struct net_device *dev, if (!spec_l2) return -ENOMEM; - mac = priv->mac & MLX4_MAC_MASK; - be_mac = cpu_to_be64(mac << 16); + if (cmd->fs.flow_type & FLOW_MAC_EXT) { + memcpy(&be_mac, cmd->fs.h_ext.h_dest, ETH_ALEN); + } else { + u64 mac = priv->mac & MLX4_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) + if ((cmd->fs.flow_type & ~(FLOW_EXT | FLOW_MAC_EXT)) != ETHER_FLOW) memcpy(spec_l2->eth.dst_mac, &be_mac, ETH_ALEN); if ((cmd->fs.flow_type & FLOW_EXT) && cmd->fs.m_ext.vlan_tci) { @@ -777,7 +786,7 @@ static int mlx4_en_ethtool_to_net_trans_rule(struct net_device *dev, list_add_tail(&spec_l2->list, rule_list_h); - switch (cmd->fs.flow_type & ~FLOW_EXT) { + switch (cmd->fs.flow_type & ~(FLOW_EXT | FLOW_MAC_EXT)) { case ETHER_FLOW: eth_spec = &cmd->fs.h_u.ether_spec; memcpy(&spec_l2->eth.dst_mac, eth_spec->h_dest, ETH_ALEN);