mlx4_core: Read extended capabilities into the flags field
authorOr Gerlitz <ogerlitz@mellanox.com>
Thu, 7 Jul 2011 19:19:29 +0000 (19:19 +0000)
committerRoland Dreier <roland@purestorage.com>
Tue, 19 Jul 2011 04:04:32 +0000 (21:04 -0700)
Query another dword containing up to 32 extended device capabilities
and merge it into struct mlx4_caps.flags.  Update the code that
handles the current extended device capabilities (e.g UDP RSS, WoL,
vep steering, etc) to use the extended device cap flags field instead
of a field per extended capability.  Initial patch done by Eli Cohen
<eli@mellanox.co.il>.

Signed-off-by: Or Gerlitz <ogerlitz@mellanox.co.il>
Signed-off-by: Roland Dreier <roland@purestorage.com>
drivers/net/mlx4/en_ethtool.c
drivers/net/mlx4/en_main.c
drivers/net/mlx4/en_netdev.c
drivers/net/mlx4/en_port.c
drivers/net/mlx4/en_selftest.c
drivers/net/mlx4/fw.c
drivers/net/mlx4/fw.h
drivers/net/mlx4/main.c
drivers/net/mlx4/mcg.c
drivers/net/mlx4/port.c
include/linux/mlx4/device.h

index 2e858e4dcf4d821d2371c948de3c48b13cbc23c5..eb096253d7818a6005f112eabe047769e3f9eab3 100644 (file)
@@ -104,7 +104,7 @@ static void mlx4_en_get_wol(struct net_device *netdev,
        int err = 0;
        u64 config = 0;
 
-       if (!priv->mdev->dev->caps.wol) {
+       if (!(priv->mdev->dev->caps.flags & MLX4_DEV_CAP_FLAG_WOL)) {
                wol->supported = 0;
                wol->wolopts = 0;
                return;
@@ -134,7 +134,7 @@ static int mlx4_en_set_wol(struct net_device *netdev,
        u64 config = 0;
        int err = 0;
 
-       if (!priv->mdev->dev->caps.wol)
+       if (!(priv->mdev->dev->caps.flags & MLX4_DEV_CAP_FLAG_WOL))
                return -EOPNOTSUPP;
 
        if (wol->supported & ~WAKE_MAGIC)
@@ -170,7 +170,8 @@ static int mlx4_en_get_sset_count(struct net_device *dev, int sset)
                return NUM_ALL_STATS +
                        (priv->tx_ring_num + priv->rx_ring_num) * 2;
        case ETH_SS_TEST:
-               return MLX4_EN_NUM_SELF_TEST - !(priv->mdev->dev->caps.loopback_support) * 2;
+               return MLX4_EN_NUM_SELF_TEST - !(priv->mdev->dev->caps.flags
+                                       & MLX4_DEV_CAP_FLAG_UC_LOOPBACK) * 2;
        default:
                return -EOPNOTSUPP;
        }
@@ -220,7 +221,7 @@ static void mlx4_en_get_strings(struct net_device *dev,
        case ETH_SS_TEST:
                for (i = 0; i < MLX4_EN_NUM_SELF_TEST - 2; i++)
                        strcpy(data + i * ETH_GSTRING_LEN, mlx4_en_test_names[i]);
-               if (priv->mdev->dev->caps.loopback_support)
+               if (priv->mdev->dev->caps.flags & MLX4_DEV_CAP_FLAG_UC_LOOPBACK)
                        for (; i < MLX4_EN_NUM_SELF_TEST; i++)
                                strcpy(data + i * ETH_GSTRING_LEN, mlx4_en_test_names[i]);
                break;
index 9276b1b25586bc17dc146f56fc05399dd8bf6ed2..6bfea233a9f27b93f9c7a2d37e03ffe553ded215 100644 (file)
@@ -106,7 +106,8 @@ static int mlx4_en_get_profile(struct mlx4_en_dev *mdev)
 
        params->tcp_rss = tcp_rss;
        params->udp_rss = udp_rss;
-       if (params->udp_rss && !mdev->dev->caps.udp_rss) {
+       if (params->udp_rss && !(mdev->dev->caps.flags
+                                       & MLX4_DEV_CAP_FLAG_UDP_RSS)) {
                mlx4_warn(mdev, "UDP RSS is not supported on this device.\n");
                params->udp_rss = 0;
        }
index 61850adae6f77a071fb29307ffbb59c517ff8892..aa6e73e7b6bbee80156598d010d2c1d84d31a22e 100644 (file)
@@ -239,7 +239,8 @@ static void mlx4_en_do_set_multicast(struct work_struct *work)
                        priv->flags |= MLX4_EN_FLAG_PROMISC;
 
                        /* Enable promiscouos mode */
-                       if (!mdev->dev->caps.vep_uc_steering)
+                       if (!(mdev->dev->caps.flags &
+                                               MLX4_DEV_CAP_FLAG_VEP_UC_STEER))
                                err = mlx4_SET_PORT_qpn_calc(mdev->dev, priv->port,
                                                             priv->base_qpn, 1);
                        else
@@ -285,7 +286,7 @@ static void mlx4_en_do_set_multicast(struct work_struct *work)
                priv->flags &= ~MLX4_EN_FLAG_PROMISC;
 
                /* Disable promiscouos mode */
-               if (!mdev->dev->caps.vep_uc_steering)
+               if (!(mdev->dev->caps.flags & MLX4_DEV_CAP_FLAG_VEP_UC_STEER))
                        err = mlx4_SET_PORT_qpn_calc(mdev->dev, priv->port,
                                                     priv->base_qpn, 0);
                else
index f2a4f5dd313d59872b208046f2c8328bfb1c726b..be861fbc1a4da93a6bb1d2029429d6e46afde29b 100644 (file)
@@ -119,9 +119,11 @@ int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn,
        struct mlx4_set_port_rqp_calc_context *context;
        int err;
        u32 in_mod;
-       u32 m_promisc = (dev->caps.vep_mc_steering) ? MCAST_DIRECT : MCAST_DEFAULT;
+       u32 m_promisc = (dev->caps.flags & MLX4_DEV_CAP_FLAG_VEP_MC_STEER) ?
+                                               MCAST_DIRECT : MCAST_DEFAULT;
 
-       if (dev->caps.vep_mc_steering && dev->caps.vep_uc_steering)
+       if (dev->caps.flags & MLX4_DEV_CAP_FLAG_VEP_MC_STEER  &&
+                       dev->caps.flags & MLX4_DEV_CAP_FLAG_VEP_UC_STEER)
                return 0;
 
        mailbox = mlx4_alloc_cmd_mailbox(dev);
index 191a8dcd8a93af1e668121d0853dc1127f3fc34c..9fdbcecd499dad25b70c23bc4369e7009ce5eb87 100644 (file)
@@ -159,7 +159,8 @@ retry_tx:
                                goto retry_tx;
                }
 
-               if (priv->mdev->dev->caps.loopback_support){
+               if (priv->mdev->dev->caps.flags &
+                                       MLX4_DEV_CAP_FLAG_UC_LOOPBACK) {
                        buf[3] = mlx4_en_test_registers(priv);
                        buf[4] = mlx4_en_test_loopback(priv);
                }
index 346d8b3d03df516dce0e394c3db31a86461e3f46..1d3fc6d7689b474e1d80085fa7774b46270d646e 100644 (file)
@@ -99,7 +99,12 @@ static void dump_dev_cap_flags(struct mlx4_dev *dev, u64 flags)
                [21] = "UD multicast support",
                [24] = "Demand paging support",
                [25] = "Router support",
-               [30] = "IBoE support"
+               [30] = "IBoE support",
+               [32] = "Unicast loopback support",
+               [38] = "Wake On LAN support",
+               [40] = "UDP RSS support",
+               [41] = "Unicast VEP steering support",
+               [42] = "Multicast VEP steering support"
        };
        int i;
 
@@ -142,7 +147,7 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
        struct mlx4_cmd_mailbox *mailbox;
        u32 *outbox;
        u8 field;
-       u32 field32, flags;
+       u32 field32, flags, ext_flags;
        u16 size;
        u16 stat_rate;
        int err;
@@ -180,8 +185,7 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
 #define QUERY_DEV_CAP_MAX_GID_OFFSET           0x3b
 #define QUERY_DEV_CAP_RATE_SUPPORT_OFFSET      0x3c
 #define QUERY_DEV_CAP_MAX_PKEY_OFFSET          0x3f
-#define QUERY_DEV_CAP_UDP_RSS_OFFSET           0x42
-#define QUERY_DEV_CAP_ETH_UC_LOOPBACK_OFFSET   0x43
+#define QUERY_DEV_CAP_EXT_FLAGS_OFFSET         0x40
 #define QUERY_DEV_CAP_FLAGS_OFFSET             0x44
 #define QUERY_DEV_CAP_RSVD_UAR_OFFSET          0x48
 #define QUERY_DEV_CAP_UAR_SZ_OFFSET            0x49
@@ -272,15 +276,9 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
        dev_cap->max_msg_sz = 1 << (field & 0x1f);
        MLX4_GET(stat_rate, outbox, QUERY_DEV_CAP_RATE_SUPPORT_OFFSET);
        dev_cap->stat_rate_support = stat_rate;
-       MLX4_GET(field, outbox, QUERY_DEV_CAP_UDP_RSS_OFFSET);
-       dev_cap->udp_rss = field & 0x1;
-       dev_cap->vep_uc_steering = field & 0x2;
-       dev_cap->vep_mc_steering = field & 0x4;
-       MLX4_GET(field, outbox, QUERY_DEV_CAP_ETH_UC_LOOPBACK_OFFSET);
-       dev_cap->loopback_support = field & 0x1;
-       dev_cap->wol = field & 0x40;
+       MLX4_GET(ext_flags, outbox, QUERY_DEV_CAP_EXT_FLAGS_OFFSET);
        MLX4_GET(flags, outbox, QUERY_DEV_CAP_FLAGS_OFFSET);
-       dev_cap->flags = flags;
+       dev_cap->flags = flags | (u64)ext_flags << 32;
        MLX4_GET(field, outbox, QUERY_DEV_CAP_RSVD_UAR_OFFSET);
        dev_cap->reserved_uars = field >> 4;
        MLX4_GET(field, outbox, QUERY_DEV_CAP_UAR_SZ_OFFSET);
@@ -802,7 +800,7 @@ int mlx4_INIT_HCA(struct mlx4_dev *dev, struct mlx4_init_hca_param *param)
        MLX4_PUT(inbox, param->mc_base,         INIT_HCA_MC_BASE_OFFSET);
        MLX4_PUT(inbox, param->log_mc_entry_sz, INIT_HCA_LOG_MC_ENTRY_SZ_OFFSET);
        MLX4_PUT(inbox, param->log_mc_hash_sz,  INIT_HCA_LOG_MC_HASH_SZ_OFFSET);
-       if (dev->caps.vep_mc_steering)
+       if (dev->caps.flags & MLX4_DEV_CAP_FLAG_VEP_MC_STEER)
                MLX4_PUT(inbox, (u8) (1 << 3),  INIT_HCA_UC_STEERING_OFFSET);
        MLX4_PUT(inbox, param->log_mc_table_sz, INIT_HCA_LOG_MC_TABLE_SZ_OFFSET);
 
index 2a8d11008c5128fd990506d54950c6f7f127f74c..56ed1646ccedff739150a135163e58591a7822a5 100644 (file)
@@ -78,11 +78,6 @@ struct mlx4_dev_cap {
        u16 wavelength[MLX4_MAX_PORTS + 1];
        u64 trans_code[MLX4_MAX_PORTS + 1];
        u16 stat_rate_support;
-       int udp_rss;
-       int loopback_support;
-       int vep_uc_steering;
-       int vep_mc_steering;
-       int wol;
        u64 flags;
        int reserved_uars;
        int uar_size;
index 3814fc9b1145d50fc6fe25426436f895d9010b63..650f4ca8606e8b190683af2e6900e7bfdb9d2008 100644 (file)
@@ -226,11 +226,6 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
        dev->caps.bmme_flags         = dev_cap->bmme_flags;
        dev->caps.reserved_lkey      = dev_cap->reserved_lkey;
        dev->caps.stat_rate_support  = dev_cap->stat_rate_support;
-       dev->caps.udp_rss            = dev_cap->udp_rss;
-       dev->caps.loopback_support   = dev_cap->loopback_support;
-       dev->caps.vep_uc_steering    = dev_cap->vep_uc_steering;
-       dev->caps.vep_mc_steering    = dev_cap->vep_mc_steering;
-       dev->caps.wol                = dev_cap->wol;
        dev->caps.max_gso_sz         = dev_cap->max_gso_sz;
 
        dev->caps.log_num_macs  = log_num_mac;
index e63c37d6a11506f8d91f937b2eab7b481ed32a11..cd1784593a3c9c98706240da59f922d6c3bdbc82 100644 (file)
@@ -559,7 +559,8 @@ static int find_entry(struct mlx4_dev *dev, u8 port,
        struct mlx4_mgm *mgm = mgm_mailbox->buf;
        u8 *mgid;
        int err;
-       u8 op_mod = (prot == MLX4_PROT_ETH) ? !!(dev->caps.vep_mc_steering) : 0;
+       u8 op_mod = (prot == MLX4_PROT_ETH) ?
+               !!(dev->caps.flags & MLX4_DEV_CAP_FLAG_VEP_MC_STEER) : 0;
 
        mailbox = mlx4_alloc_cmd_mailbox(dev);
        if (IS_ERR(mailbox))
@@ -834,7 +835,8 @@ int mlx4_multicast_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
 
        steer = (is_valid_ether_addr(&gid[10])) ? MLX4_UC_STEER : MLX4_MC_STEER;
 
-       if (prot == MLX4_PROT_ETH && !dev->caps.vep_mc_steering)
+       if (prot == MLX4_PROT_ETH &&
+                       !(dev->caps.flags & MLX4_DEV_CAP_FLAG_VEP_MC_STEER))
                return 0;
 
        if (prot == MLX4_PROT_ETH)
@@ -853,7 +855,8 @@ int mlx4_multicast_detach(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
 
        steer = (is_valid_ether_addr(&gid[10])) ? MLX4_UC_STEER : MLX4_MC_STEER;
 
-       if (prot == MLX4_PROT_ETH && !dev->caps.vep_mc_steering)
+       if (prot == MLX4_PROT_ETH &&
+                       !(dev->caps.flags & MLX4_DEV_CAP_FLAG_VEP_MC_STEER))
                return 0;
 
        if (prot == MLX4_PROT_ETH) {
@@ -867,7 +870,7 @@ EXPORT_SYMBOL_GPL(mlx4_multicast_detach);
 
 int mlx4_multicast_promisc_add(struct mlx4_dev *dev, u32 qpn, u8 port)
 {
-       if (!dev->caps.vep_mc_steering)
+       if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_VEP_MC_STEER))
                return 0;
 
 
@@ -877,7 +880,7 @@ EXPORT_SYMBOL_GPL(mlx4_multicast_promisc_add);
 
 int mlx4_multicast_promisc_remove(struct mlx4_dev *dev, u32 qpn, u8 port)
 {
-       if (!dev->caps.vep_mc_steering)
+       if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_VEP_MC_STEER))
                return 0;
 
 
@@ -887,7 +890,7 @@ EXPORT_SYMBOL_GPL(mlx4_multicast_promisc_remove);
 
 int mlx4_unicast_promisc_add(struct mlx4_dev *dev, u32 qpn, u8 port)
 {
-       if (!dev->caps.vep_mc_steering)
+       if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_VEP_MC_STEER))
                return 0;
 
 
@@ -897,7 +900,7 @@ EXPORT_SYMBOL_GPL(mlx4_unicast_promisc_add);
 
 int mlx4_unicast_promisc_remove(struct mlx4_dev *dev, u32 qpn, u8 port)
 {
-       if (!dev->caps.vep_mc_steering)
+       if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_VEP_MC_STEER))
                return 0;
 
        return remove_promisc_qp(dev, 0, port, MLX4_UC_STEER, qpn);
index 8856659fb43c4a23d2280a2a3062ce2bd9453b35..1f95afda68410ad9794c0425366b6dd9c6aa7663 100644 (file)
@@ -146,7 +146,7 @@ int mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac, int *qpn, u8 wrap)
        int i, err = 0;
        int free = -1;
 
-       if (dev->caps.vep_uc_steering) {
+       if (dev->caps.flags & MLX4_DEV_CAP_FLAG_VEP_UC_STEER) {
                err = mlx4_uc_steer_add(dev, port, mac, qpn, 1);
                if (!err) {
                        entry = kmalloc(sizeof *entry, GFP_KERNEL);
@@ -203,7 +203,7 @@ int mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac, int *qpn, u8 wrap)
                goto out;
        }
 
-       if (!dev->caps.vep_uc_steering)
+       if (!(dev->caps.flags & MLX4_DEV_CAP_FLAG_VEP_UC_STEER))
                *qpn = info->base_qpn + free;
        ++table->total;
 out:
@@ -243,7 +243,7 @@ void mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, int qpn)
        int index = qpn - info->base_qpn;
        struct mlx4_mac_entry *entry;
 
-       if (dev->caps.vep_uc_steering) {
+       if (dev->caps.flags & MLX4_DEV_CAP_FLAG_VEP_UC_STEER) {
                entry = radix_tree_lookup(&info->mac_tree, qpn);
                if (entry) {
                        mlx4_uc_steer_release(dev, port, entry->mac, qpn, 1);
@@ -274,7 +274,7 @@ int mlx4_replace_mac(struct mlx4_dev *dev, u8 port, int qpn, u64 new_mac, u8 wra
        struct mlx4_mac_entry *entry;
        int err;
 
-       if (dev->caps.vep_uc_steering) {
+       if (dev->caps.flags & MLX4_DEV_CAP_FLAG_VEP_UC_STEER) {
                entry = radix_tree_lookup(&info->mac_tree, qpn);
                if (!entry)
                        return -EINVAL;
index f337e989b70f3d90760893d1b8ae192ae1e69c6f..fa861134928aef7e08ea52bf68412d2f40c04ec5 100644 (file)
@@ -73,7 +73,12 @@ enum {
        MLX4_DEV_CAP_FLAG_RAW_MCAST     = 1LL << 19,
        MLX4_DEV_CAP_FLAG_UD_AV_PORT    = 1LL << 20,
        MLX4_DEV_CAP_FLAG_UD_MCAST      = 1LL << 21,
-       MLX4_DEV_CAP_FLAG_IBOE          = 1LL << 30
+       MLX4_DEV_CAP_FLAG_IBOE          = 1LL << 30,
+       MLX4_DEV_CAP_FLAG_UC_LOOPBACK   = 1LL << 32,
+       MLX4_DEV_CAP_FLAG_WOL           = 1LL << 38,
+       MLX4_DEV_CAP_FLAG_UDP_RSS       = 1LL << 40,
+       MLX4_DEV_CAP_FLAG_VEP_UC_STEER  = 1LL << 41,
+       MLX4_DEV_CAP_FLAG_VEP_MC_STEER  = 1LL << 42
 };
 
 enum {
@@ -257,11 +262,6 @@ struct mlx4_caps {
        u32                     bmme_flags;
        u32                     reserved_lkey;
        u16                     stat_rate_support;
-       int                     udp_rss;
-       int                     loopback_support;
-       int                     vep_uc_steering;
-       int                     vep_mc_steering;
-       int                     wol;
        u8                      port_width_cap[MLX4_MAX_PORTS + 1];
        int                     max_gso_sz;
        int                     reserved_qps_cnt[MLX4_NUM_QP_REGION];