net/mlx5: E-Switch, Set vport representor fields explicitly on registration
authorOr Gerlitz <ogerlitz@mellanox.com>
Thu, 22 Sep 2016 17:01:43 +0000 (20:01 +0300)
committerDavid S. Miller <davem@davemloft.net>
Fri, 23 Sep 2016 11:22:12 +0000 (07:22 -0400)
The structure we use for the eswitch vport representor (mlx5_eswitch_rep)
has some fields which are set from upper layers in the driver when they
register the rep. Use explicit setting on registration time for them and
avoid global memcpy. This patch doesn't add new functionality.

Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c

index 6d8c5a2fbb63a49db1132cc62de27d8ab2a5cc59..ebfcde02a5dbe259a4f07d678111a3deff8e67cc 100644 (file)
@@ -178,11 +178,12 @@ struct mlx5_eswitch_rep {
        void                   (*unload)(struct mlx5_eswitch *esw,
                                         struct mlx5_eswitch_rep *rep);
        u16                    vport;
-       struct mlx5_flow_rule *vport_rx_rule;
+       u8                     hw_id[ETH_ALEN];
        void                  *priv_data;
+
+       struct mlx5_flow_rule *vport_rx_rule;
        struct list_head       vport_sqs_list;
        bool                   valid;
-       u8                     hw_id[ETH_ALEN];
 };
 
 struct mlx5_esw_offload {
index 516ac9920b758dc710213c3614a3bd506e9f2889..80c6f4f7487b5ce382c3e894c7a6e61b682c18b5 100644 (file)
@@ -624,7 +624,13 @@ void mlx5_eswitch_register_vport_rep(struct mlx5_eswitch *esw,
 
        rep = &offloads->vport_reps[vport_index];
 
-       memcpy(rep, __rep, sizeof(struct mlx5_eswitch_rep));
+       memset(rep, 0, sizeof(*rep));
+
+       rep->load   = __rep->load;
+       rep->unload = __rep->unload;
+       rep->vport  = __rep->vport;
+       rep->priv_data = __rep->priv_data;
+       ether_addr_copy(rep->hw_id, __rep->hw_id);
 
        INIT_LIST_HEAD(&rep->vport_sqs_list);
        rep->valid = true;