Skip to content
  1. Jan 05, 2022
    • Vladimir Oltean's avatar
      net: dsa: merge all bools of struct dsa_switch into a single u32 · 7787ff77
      Vladimir Oltean authored
      
      
      struct dsa_switch has 9 boolean properties, many of which are in fact
      set by drivers for custom behavior (vlan_filtering_is_global,
      needs_standalone_vlan_filtering, etc etc). The binary layout of the
      structure could be improved. For example, the "bool setup" at the
      beginning introduces a gratuitous 7 byte hole in the first cache line.
      
      The change merges all boolean properties into bitfields of an u32, and
      places that u32 in the first cache line of the structure, since many
      bools are accessed from the data path (untag_bridge_pvid, vlan_filtering,
      vlan_filtering_is_global).
      
      We place this u32 after the existing ds->index, which is also 4 bytes in
      size. As a positive side effect, ds->tagger_data now fits into the first
      cache line too, because 4 bytes are saved.
      
      Before:
      
      pahole -C dsa_switch net/dsa/slave.o
      struct dsa_switch {
              bool                       setup;                /*     0     1 */
      
              /* XXX 7 bytes hole, try to pack */
      
              struct device *            dev;                  /*     8     8 */
              struct dsa_switch_tree *   dst;                  /*    16     8 */
              unsigned int               index;                /*    24     4 */
      
              /* XXX 4 bytes hole, try to pack */
      
              struct notifier_block      nb;                   /*    32    24 */
      
              /* XXX last struct has 4 bytes of padding */
      
              void *                     priv;                 /*    56     8 */
              /* --- cacheline 1 boundary (64 bytes) --- */
              void *                     tagger_data;          /*    64     8 */
              struct dsa_chip_data *     cd;                   /*    72     8 */
              const struct dsa_switch_ops  * ops;              /*    80     8 */
              u32                        phys_mii_mask;        /*    88     4 */
      
              /* XXX 4 bytes hole, try to pack */
      
              struct mii_bus *           slave_mii_bus;        /*    96     8 */
              unsigned int               ageing_time_min;      /*   104     4 */
              unsigned int               ageing_time_max;      /*   108     4 */
              struct dsa_8021q_context * tag_8021q_ctx;        /*   112     8 */
              struct devlink *           devlink;              /*   120     8 */
              /* --- cacheline 2 boundary (128 bytes) --- */
              unsigned int               num_tx_queues;        /*   128     4 */
              bool                       vlan_filtering_is_global; /*   132     1 */
              bool                       needs_standalone_vlan_filtering; /*   133     1 */
              bool                       configure_vlan_while_not_filtering; /*   134     1 */
              bool                       untag_bridge_pvid;    /*   135     1 */
              bool                       assisted_learning_on_cpu_port; /*   136     1 */
              bool                       vlan_filtering;       /*   137     1 */
              bool                       pcs_poll;             /*   138     1 */
              bool                       mtu_enforcement_ingress; /*   139     1 */
              unsigned int               num_lag_ids;          /*   140     4 */
              unsigned int               max_num_bridges;      /*   144     4 */
      
              /* XXX 4 bytes hole, try to pack */
      
              size_t                     num_ports;            /*   152     8 */
      
              /* size: 160, cachelines: 3, members: 27 */
              /* sum members: 141, holes: 4, sum holes: 19 */
              /* paddings: 1, sum paddings: 4 */
              /* last cacheline: 32 bytes */
      };
      
      After:
      
      pahole -C dsa_switch net/dsa/slave.o
      struct dsa_switch {
              struct device *            dev;                  /*     0     8 */
              struct dsa_switch_tree *   dst;                  /*     8     8 */
              unsigned int               index;                /*    16     4 */
              u32                        setup:1;              /*    20: 0  4 */
              u32                        vlan_filtering_is_global:1; /*    20: 1  4 */
              u32                        needs_standalone_vlan_filtering:1; /*    20: 2  4 */
              u32                        configure_vlan_while_not_filtering:1; /*    20: 3  4 */
              u32                        untag_bridge_pvid:1;  /*    20: 4  4 */
              u32                        assisted_learning_on_cpu_port:1; /*    20: 5  4 */
              u32                        vlan_filtering:1;     /*    20: 6  4 */
              u32                        pcs_poll:1;           /*    20: 7  4 */
              u32                        mtu_enforcement_ingress:1; /*    20: 8  4 */
      
              /* XXX 23 bits hole, try to pack */
      
              struct notifier_block      nb;                   /*    24    24 */
      
              /* XXX last struct has 4 bytes of padding */
      
              void *                     priv;                 /*    48     8 */
              void *                     tagger_data;          /*    56     8 */
              /* --- cacheline 1 boundary (64 bytes) --- */
              struct dsa_chip_data *     cd;                   /*    64     8 */
              const struct dsa_switch_ops  * ops;              /*    72     8 */
              u32                        phys_mii_mask;        /*    80     4 */
      
              /* XXX 4 bytes hole, try to pack */
      
              struct mii_bus *           slave_mii_bus;        /*    88     8 */
              unsigned int               ageing_time_min;      /*    96     4 */
              unsigned int               ageing_time_max;      /*   100     4 */
              struct dsa_8021q_context * tag_8021q_ctx;        /*   104     8 */
              struct devlink *           devlink;              /*   112     8 */
              unsigned int               num_tx_queues;        /*   120     4 */
              unsigned int               num_lag_ids;          /*   124     4 */
              /* --- cacheline 2 boundary (128 bytes) --- */
              unsigned int               max_num_bridges;      /*   128     4 */
      
              /* XXX 4 bytes hole, try to pack */
      
              size_t                     num_ports;            /*   136     8 */
      
              /* size: 144, cachelines: 3, members: 27 */
              /* sum members: 132, holes: 2, sum holes: 8 */
              /* sum bitfield members: 9 bits, bit holes: 1, sum bit holes: 23 bits */
              /* paddings: 1, sum paddings: 4 */
              /* last cacheline: 16 bytes */
      };
      
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7787ff77
    • Vladimir Oltean's avatar
      net: dsa: move dsa_port :: type near dsa_port :: index · 06251258
      Vladimir Oltean authored
      
      
      Both dsa_port :: type and dsa_port :: index introduce a 4 octet hole
      after them, so we can group them together and the holes would be
      eliminated, turning 16 octets of storage into just 8. This makes the
      cpu_dp pointer fit in the first cache line, which is good, because
      dsa_slave_to_master(), called by dsa_enqueue_skb(), uses it.
      
      Before:
      
      pahole -C dsa_port net/dsa/slave.o
      struct dsa_port {
              union {
                      struct net_device * master;              /*     0     8 */
                      struct net_device * slave;               /*     0     8 */
              };                                               /*     0     8 */
              const struct dsa_device_ops  * tag_ops;          /*     8     8 */
              struct dsa_switch_tree *   dst;                  /*    16     8 */
              struct sk_buff *           (*rcv)(struct sk_buff *, struct net_device *); /*    24     8 */
              enum {
                      DSA_PORT_TYPE_UNUSED = 0,
                      DSA_PORT_TYPE_CPU    = 1,
                      DSA_PORT_TYPE_DSA    = 2,
                      DSA_PORT_TYPE_USER   = 3,
              } type;                                          /*    32     4 */
      
              /* XXX 4 bytes hole, try to pack */
      
              struct dsa_switch *        ds;                   /*    40     8 */
              unsigned int               index;                /*    48     4 */
      
              /* XXX 4 bytes hole, try to pack */
      
              const char  *              name;                 /*    56     8 */
              /* --- cacheline 1 boundary (64 bytes) --- */
              struct dsa_port *          cpu_dp;               /*    64     8 */
              u8                         mac[6];               /*    72     6 */
              u8                         stp_state;            /*    78     1 */
              u8                         vlan_filtering:1;     /*    79: 0  1 */
              u8                         learning:1;           /*    79: 1  1 */
              u8                         lag_tx_enabled:1;     /*    79: 2  1 */
              u8                         devlink_port_setup:1; /*    79: 3  1 */
              u8                         setup:1;              /*    79: 4  1 */
      
              /* XXX 3 bits hole, try to pack */
      
              struct device_node *       dn;                   /*    80     8 */
              unsigned int               ageing_time;          /*    88     4 */
      
              /* XXX 4 bytes hole, try to pack */
      
              struct dsa_bridge *        bridge;               /*    96     8 */
              struct devlink_port        devlink_port;         /*   104   288 */
              /* --- cacheline 6 boundary (384 bytes) was 8 bytes ago --- */
              struct phylink *           pl;                   /*   392     8 */
              struct phylink_config      pl_config;            /*   400    40 */
              struct net_device *        lag_dev;              /*   440     8 */
              /* --- cacheline 7 boundary (448 bytes) --- */
              struct net_device *        hsr_dev;              /*   448     8 */
              struct list_head           list;                 /*   456    16 */
              const struct ethtool_ops  * orig_ethtool_ops;    /*   472     8 */
              const struct dsa_netdevice_ops  * netdev_ops;    /*   480     8 */
              struct mutex               addr_lists_lock;      /*   488    32 */
              /* --- cacheline 8 boundary (512 bytes) was 8 bytes ago --- */
              struct list_head           fdbs;                 /*   520    16 */
              struct list_head           mdbs;                 /*   536    16 */
      
              /* size: 552, cachelines: 9, members: 30 */
              /* sum members: 539, holes: 3, sum holes: 12 */
              /* sum bitfield members: 5 bits, bit holes: 1, sum bit holes: 3 bits */
              /* last cacheline: 40 bytes */
      };
      
      After:
      
      pahole -C dsa_port net/dsa/slave.o
      struct dsa_port {
              union {
                      struct net_device * master;              /*     0     8 */
                      struct net_device * slave;               /*     0     8 */
              };                                               /*     0     8 */
              const struct dsa_device_ops  * tag_ops;          /*     8     8 */
              struct dsa_switch_tree *   dst;                  /*    16     8 */
              struct sk_buff *           (*rcv)(struct sk_buff *, struct net_device *); /*    24     8 */
              struct dsa_switch *        ds;                   /*    32     8 */
              unsigned int               index;                /*    40     4 */
              enum {
                      DSA_PORT_TYPE_UNUSED = 0,
                      DSA_PORT_TYPE_CPU    = 1,
                      DSA_PORT_TYPE_DSA    = 2,
                      DSA_PORT_TYPE_USER   = 3,
              } type;                                          /*    44     4 */
              const char  *              name;                 /*    48     8 */
              struct dsa_port *          cpu_dp;               /*    56     8 */
              /* --- cacheline 1 boundary (64 bytes) --- */
              u8                         mac[6];               /*    64     6 */
              u8                         stp_state;            /*    70     1 */
              u8                         vlan_filtering:1;     /*    71: 0  1 */
              u8                         learning:1;           /*    71: 1  1 */
              u8                         lag_tx_enabled:1;     /*    71: 2  1 */
              u8                         devlink_port_setup:1; /*    71: 3  1 */
              u8                         setup:1;              /*    71: 4  1 */
      
              /* XXX 3 bits hole, try to pack */
      
              struct device_node *       dn;                   /*    72     8 */
              unsigned int               ageing_time;          /*    80     4 */
      
              /* XXX 4 bytes hole, try to pack */
      
              struct dsa_bridge *        bridge;               /*    88     8 */
              struct devlink_port        devlink_port;         /*    96   288 */
              /* --- cacheline 6 boundary (384 bytes) --- */
              struct phylink *           pl;                   /*   384     8 */
              struct phylink_config      pl_config;            /*   392    40 */
              struct net_device *        lag_dev;              /*   432     8 */
              struct net_device *        hsr_dev;              /*   440     8 */
              /* --- cacheline 7 boundary (448 bytes) --- */
              struct list_head           list;                 /*   448    16 */
              const struct ethtool_ops  * orig_ethtool_ops;    /*   464     8 */
              const struct dsa_netdevice_ops  * netdev_ops;    /*   472     8 */
              struct mutex               addr_lists_lock;      /*   480    32 */
              /* --- cacheline 8 boundary (512 bytes) --- */
              struct list_head           fdbs;                 /*   512    16 */
              struct list_head           mdbs;                 /*   528    16 */
      
              /* size: 544, cachelines: 9, members: 30 */
              /* sum members: 539, holes: 1, sum holes: 4 */
              /* sum bitfield members: 5 bits, bit holes: 1, sum bit holes: 3 bits */
              /* last cacheline: 32 bytes */
      };
      
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      06251258
    • Vladimir Oltean's avatar
      net: dsa: merge all bools of struct dsa_port into a single u8 · bde82f38
      Vladimir Oltean authored
      
      
      struct dsa_port has 5 bool members which create quite a number of 7 byte
      holes in the structure layout. By merging them all into bitfields of an
      u8, and placing that u8 in the 1-byte hole after dp->mac and dp->stp_state,
      we can reduce the structure size from 576 bytes to 552 bytes on arm64.
      
      Before:
      
      pahole -C dsa_port net/dsa/slave.o
      struct dsa_port {
              union {
                      struct net_device * master;              /*     0     8 */
                      struct net_device * slave;               /*     0     8 */
              };                                               /*     0     8 */
              const struct dsa_device_ops  * tag_ops;          /*     8     8 */
              struct dsa_switch_tree *   dst;                  /*    16     8 */
              struct sk_buff *           (*rcv)(struct sk_buff *, struct net_device *); /*    24     8 */
              enum {
                      DSA_PORT_TYPE_UNUSED = 0,
                      DSA_PORT_TYPE_CPU    = 1,
                      DSA_PORT_TYPE_DSA    = 2,
                      DSA_PORT_TYPE_USER   = 3,
              } type;                                          /*    32     4 */
      
              /* XXX 4 bytes hole, try to pack */
      
              struct dsa_switch *        ds;                   /*    40     8 */
              unsigned int               index;                /*    48     4 */
      
              /* XXX 4 bytes hole, try to pack */
      
              const char  *              name;                 /*    56     8 */
              /* --- cacheline 1 boundary (64 bytes) --- */
              struct dsa_port *          cpu_dp;               /*    64     8 */
              u8                         mac[6];               /*    72     6 */
              u8                         stp_state;            /*    78     1 */
      
              /* XXX 1 byte hole, try to pack */
      
              struct device_node *       dn;                   /*    80     8 */
              unsigned int               ageing_time;          /*    88     4 */
              bool                       vlan_filtering;       /*    92     1 */
              bool                       learning;             /*    93     1 */
      
              /* XXX 2 bytes hole, try to pack */
      
              struct dsa_bridge *        bridge;               /*    96     8 */
              struct devlink_port        devlink_port;         /*   104   288 */
              /* --- cacheline 6 boundary (384 bytes) was 8 bytes ago --- */
              bool                       devlink_port_setup;   /*   392     1 */
      
              /* XXX 7 bytes hole, try to pack */
      
              struct phylink *           pl;                   /*   400     8 */
              struct phylink_config      pl_config;            /*   408    40 */
              /* --- cacheline 7 boundary (448 bytes) --- */
              struct net_device *        lag_dev;              /*   448     8 */
              bool                       lag_tx_enabled;       /*   456     1 */
      
              /* XXX 7 bytes hole, try to pack */
      
              struct net_device *        hsr_dev;              /*   464     8 */
              struct list_head           list;                 /*   472    16 */
              const struct ethtool_ops  * orig_ethtool_ops;    /*   488     8 */
              const struct dsa_netdevice_ops  * netdev_ops;    /*   496     8 */
              struct mutex               addr_lists_lock;      /*   504    32 */
              /* --- cacheline 8 boundary (512 bytes) was 24 bytes ago --- */
              struct list_head           fdbs;                 /*   536    16 */
              struct list_head           mdbs;                 /*   552    16 */
              bool                       setup;                /*   568     1 */
      
              /* size: 576, cachelines: 9, members: 30 */
              /* sum members: 544, holes: 6, sum holes: 25 */
              /* padding: 7 */
      };
      
      After:
      
      pahole -C dsa_port net/dsa/slave.o
      struct dsa_port {
              union {
                      struct net_device * master;              /*     0     8 */
                      struct net_device * slave;               /*     0     8 */
              };                                               /*     0     8 */
              const struct dsa_device_ops  * tag_ops;          /*     8     8 */
              struct dsa_switch_tree *   dst;                  /*    16     8 */
              struct sk_buff *           (*rcv)(struct sk_buff *, struct net_device *); /*    24     8 */
              enum {
                      DSA_PORT_TYPE_UNUSED = 0,
                      DSA_PORT_TYPE_CPU    = 1,
                      DSA_PORT_TYPE_DSA    = 2,
                      DSA_PORT_TYPE_USER   = 3,
              } type;                                          /*    32     4 */
      
              /* XXX 4 bytes hole, try to pack */
      
              struct dsa_switch *        ds;                   /*    40     8 */
              unsigned int               index;                /*    48     4 */
      
              /* XXX 4 bytes hole, try to pack */
      
              const char  *              name;                 /*    56     8 */
              /* --- cacheline 1 boundary (64 bytes) --- */
              struct dsa_port *          cpu_dp;               /*    64     8 */
              u8                         mac[6];               /*    72     6 */
              u8                         stp_state;            /*    78     1 */
              u8                         vlan_filtering:1;     /*    79: 0  1 */
              u8                         learning:1;           /*    79: 1  1 */
              u8                         lag_tx_enabled:1;     /*    79: 2  1 */
              u8                         devlink_port_setup:1; /*    79: 3  1 */
              u8                         setup:1;              /*    79: 4  1 */
      
              /* XXX 3 bits hole, try to pack */
      
              struct device_node *       dn;                   /*    80     8 */
              unsigned int               ageing_time;          /*    88     4 */
      
              /* XXX 4 bytes hole, try to pack */
      
              struct dsa_bridge *        bridge;               /*    96     8 */
              struct devlink_port        devlink_port;         /*   104   288 */
              /* --- cacheline 6 boundary (384 bytes) was 8 bytes ago --- */
              struct phylink *           pl;                   /*   392     8 */
              struct phylink_config      pl_config;            /*   400    40 */
              struct net_device *        lag_dev;              /*   440     8 */
              /* --- cacheline 7 boundary (448 bytes) --- */
              struct net_device *        hsr_dev;              /*   448     8 */
              struct list_head           list;                 /*   456    16 */
              const struct ethtool_ops  * orig_ethtool_ops;    /*   472     8 */
              const struct dsa_netdevice_ops  * netdev_ops;    /*   480     8 */
              struct mutex               addr_lists_lock;      /*   488    32 */
              /* --- cacheline 8 boundary (512 bytes) was 8 bytes ago --- */
              struct list_head           fdbs;                 /*   520    16 */
              struct list_head           mdbs;                 /*   536    16 */
      
              /* size: 552, cachelines: 9, members: 30 */
              /* sum members: 539, holes: 3, sum holes: 12 */
              /* sum bitfield members: 5 bits, bit holes: 1, sum bit holes: 3 bits */
              /* last cacheline: 40 bytes */
      };
      
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      bde82f38
    • Vladimir Oltean's avatar
      net: dsa: move dsa_port :: stp_state near dsa_port :: mac · b08db33d
      Vladimir Oltean authored
      
      
      The MAC address of a port is 6 octets in size, and this creates a 2
      octet hole after it. There are some other u8 members of struct dsa_port
      that we can put in that hole. One such member is the stp_state.
      
      Before:
      
      pahole -C dsa_port net/dsa/slave.o
      struct dsa_port {
              union {
                      struct net_device * master;              /*     0     8 */
                      struct net_device * slave;               /*     0     8 */
              };                                               /*     0     8 */
              const struct dsa_device_ops  * tag_ops;          /*     8     8 */
              struct dsa_switch_tree *   dst;                  /*    16     8 */
              struct sk_buff *           (*rcv)(struct sk_buff *, struct net_device *); /*    24     8 */
              enum {
                      DSA_PORT_TYPE_UNUSED = 0,
                      DSA_PORT_TYPE_CPU    = 1,
                      DSA_PORT_TYPE_DSA    = 2,
                      DSA_PORT_TYPE_USER   = 3,
              } type;                                          /*    32     4 */
      
              /* XXX 4 bytes hole, try to pack */
      
              struct dsa_switch *        ds;                   /*    40     8 */
              unsigned int               index;                /*    48     4 */
      
              /* XXX 4 bytes hole, try to pack */
      
              const char  *              name;                 /*    56     8 */
              /* --- cacheline 1 boundary (64 bytes) --- */
              struct dsa_port *          cpu_dp;               /*    64     8 */
              u8                         mac[6];               /*    72     6 */
      
              /* XXX 2 bytes hole, try to pack */
      
              struct device_node *       dn;                   /*    80     8 */
              unsigned int               ageing_time;          /*    88     4 */
              bool                       vlan_filtering;       /*    92     1 */
              bool                       learning;             /*    93     1 */
              u8                         stp_state;            /*    94     1 */
      
              /* XXX 1 byte hole, try to pack */
      
              struct dsa_bridge *        bridge;               /*    96     8 */
              struct devlink_port        devlink_port;         /*   104   288 */
              /* --- cacheline 6 boundary (384 bytes) was 8 bytes ago --- */
              bool                       devlink_port_setup;   /*   392     1 */
      
              /* XXX 7 bytes hole, try to pack */
      
              struct phylink *           pl;                   /*   400     8 */
              struct phylink_config      pl_config;            /*   408    40 */
              /* --- cacheline 7 boundary (448 bytes) --- */
              struct net_device *        lag_dev;              /*   448     8 */
              bool                       lag_tx_enabled;       /*   456     1 */
      
              /* XXX 7 bytes hole, try to pack */
      
              struct net_device *        hsr_dev;              /*   464     8 */
              struct list_head           list;                 /*   472    16 */
              const struct ethtool_ops  * orig_ethtool_ops;    /*   488     8 */
              const struct dsa_netdevice_ops  * netdev_ops;    /*   496     8 */
              struct mutex               addr_lists_lock;      /*   504    32 */
              /* --- cacheline 8 boundary (512 bytes) was 24 bytes ago --- */
              struct list_head           fdbs;                 /*   536    16 */
              struct list_head           mdbs;                 /*   552    16 */
              bool                       setup;                /*   568     1 */
      
              /* size: 576, cachelines: 9, members: 30 */
              /* sum members: 544, holes: 6, sum holes: 25 */
              /* padding: 7 */
      };
      
      After:
      
      pahole -C dsa_port net/dsa/slave.o
      struct dsa_port {
              union {
                      struct net_device * master;              /*     0     8 */
                      struct net_device * slave;               /*     0     8 */
              };                                               /*     0     8 */
              const struct dsa_device_ops  * tag_ops;          /*     8     8 */
              struct dsa_switch_tree *   dst;                  /*    16     8 */
              struct sk_buff *           (*rcv)(struct sk_buff *, struct net_device *); /*    24     8 */
              enum {
                      DSA_PORT_TYPE_UNUSED = 0,
                      DSA_PORT_TYPE_CPU    = 1,
                      DSA_PORT_TYPE_DSA    = 2,
                      DSA_PORT_TYPE_USER   = 3,
              } type;                                          /*    32     4 */
      
              /* XXX 4 bytes hole, try to pack */
      
              struct dsa_switch *        ds;                   /*    40     8 */
              unsigned int               index;                /*    48     4 */
      
              /* XXX 4 bytes hole, try to pack */
      
              const char  *              name;                 /*    56     8 */
              /* --- cacheline 1 boundary (64 bytes) --- */
              struct dsa_port *          cpu_dp;               /*    64     8 */
              u8                         mac[6];               /*    72     6 */
              u8                         stp_state;            /*    78     1 */
      
              /* XXX 1 byte hole, try to pack */
      
              struct device_node *       dn;                   /*    80     8 */
              unsigned int               ageing_time;          /*    88     4 */
              bool                       vlan_filtering;       /*    92     1 */
              bool                       learning;             /*    93     1 */
      
              /* XXX 2 bytes hole, try to pack */
      
              struct dsa_bridge *        bridge;               /*    96     8 */
              struct devlink_port        devlink_port;         /*   104   288 */
              /* --- cacheline 6 boundary (384 bytes) was 8 bytes ago --- */
              bool                       devlink_port_setup;   /*   392     1 */
      
              /* XXX 7 bytes hole, try to pack */
      
              struct phylink *           pl;                   /*   400     8 */
              struct phylink_config      pl_config;            /*   408    40 */
              /* --- cacheline 7 boundary (448 bytes) --- */
              struct net_device *        lag_dev;              /*   448     8 */
              bool                       lag_tx_enabled;       /*   456     1 */
      
              /* XXX 7 bytes hole, try to pack */
      
              struct net_device *        hsr_dev;              /*   464     8 */
              struct list_head           list;                 /*   472    16 */
              const struct ethtool_ops  * orig_ethtool_ops;    /*   488     8 */
              const struct dsa_netdevice_ops  * netdev_ops;    /*   496     8 */
              struct mutex               addr_lists_lock;      /*   504    32 */
              /* --- cacheline 8 boundary (512 bytes) was 24 bytes ago --- */
              struct list_head           fdbs;                 /*   536    16 */
              struct list_head           mdbs;                 /*   552    16 */
              bool                       setup;                /*   568     1 */
      
              /* size: 576, cachelines: 9, members: 30 */
              /* sum members: 544, holes: 6, sum holes: 25 */
              /* padding: 7 */
      };
      
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b08db33d
    • David S. Miller's avatar
      Merge branch 'hns3-stats-refactor' · 5be9963d
      David S. Miller authored
      
      
      Jie Wang says:
      
      ====================
      net: hns3: refactor rss/tqp stats functions
      
      Currently, hns3 PF and VF module have two sets of rss and tqp stats APIs
      to provide get and set functions. Most of these APIs are the same. There is
      no need to keep these two sets of same functions for double development and
      bugfix work.
      
      This series refactor the rss and tqp stats APIs in hns3 PF and VF by
      implementing one set of common APIs for PF and VF reuse and deleting the
      old APIs.
      ====================
      
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      5be9963d
    • Jie Wang's avatar
      net: hns3: create new common cmd code for PF and VF modules · 43710bfe
      Jie Wang authored
      
      
      Currently PF and VF use two sets of command code for modules to interact
      with firmware. These codes values are same espect the macro names. It is
      redundent to keep two sets of command code for same functions between PF
      and VF.
      
      So this patch firstly creates a unified command code for PF and VF module.
      We keep the macro name same with the PF command code name to avoid too many
      meaningless modifications. Secondly the new common command codes are used
      to replace the old ones in VF and deletes the old ones.
      
      Signed-off-by: default avatarJie Wang <wangjie125@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      43710bfe
    • Jie Wang's avatar
      net: hns3: refactor VF tqp stats APIs with new common tqp stats APIs · 4afc310c
      Jie Wang authored
      
      
      This patch firstly uses new tqp struct(hclge_comm_tqp) and removes the
      old VF tqp struct(hclgevf_tqp). All the tqp stats members used in VF module
      are modified according to the new hclge_comm_tqp.
      
      Secondly VF tqp stats APIs are refactored to use new common tqp stats APIs.
      The old tqp stats APIs in VF are deleted.
      
      Signed-off-by: default avatarJie Wang <wangjie125@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4afc310c
    • Jie Wang's avatar
      net: hns3: refactor PF tqp stats APIs with new common tqp stats APIs · add7645c
      Jie Wang authored
      
      
      This patch firstly uses new tqp struct(hclge_comm_tqp) and deletes the
      old PF tqp struct(hclge_tqp). All the tqp stats members used in PF module
      are modified according to the new hclge_comm_tqp.
      
      Secondly PF tqp stats APIs are refactored to use new common tqp stats APIs.
      The old tqp stats APIs in PF are deleted.
      
      Signed-off-by: default avatarJie Wang <wangjie125@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      add7645c
    • Jie Wang's avatar
      net: hns3: create new set of common tqp stats APIs for PF and VF reuse · 287db5c4
      Jie Wang authored
      
      
      This patch creates new set of common tqp stats structures and APIs for PF
      and VF tqp stats module. Subfunctions such as get tqp stats, update tqp
      stats and reset tqp stats are inclued in this patch.
      
      These new common tqp stats APIs will be used to replace the old PF and VF
      tqp stats APIs in next patches.
      
      Signed-off-by: default avatarJie Wang <wangjie125@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      287db5c4
    • Jie Wang's avatar
      net: hns3: refactor VF rss init APIs with new common rss init APIs · 93969dc1
      Jie Wang authored
      
      
      This patch uses common rss init APIs to replace the old APIs in VF rss
      module and removes the old VF rss init APIs. Several related Subfunctions
      and macros are also modified in this patch.
      
      Signed-off-by: default avatarJie Wang <wangjie125@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      93969dc1
    • Jie Wang's avatar
      net: hns3: refactor PF rss init APIs with new common rss init APIs · 07dce03c
      Jie Wang authored
      
      
      This patch uses common rss init APIs to replace the old APIs in PF rss
      module and deletes the old PF rss init APIs. Some related subfunctions and
      macros are also modified in this patch.
      
      Signed-off-by: default avatarJie Wang <wangjie125@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      07dce03c
    • Jie Wang's avatar
      net: hns3: create new set of common rss init APIs for PF and VF reuse · 2c0d3f4c
      Jie Wang authored
      
      
      This patch creates new set of common rss init APIs for PF and VF rss
      module. Subfunctions called by rss init process are also created include
      rss tuple configuration and rss indirect table configuration.
      
      These new common rss init APIs will be used to replace the old PF and VF
      rss init APIs in next patches.
      
      Signed-off-by: default avatarJie Wang <wangjie125@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      2c0d3f4c
    • Jie Wang's avatar
      net: hns3: refactor VF rss set APIs with new common rss set APIs · 7428d6c9
      Jie Wang authored
      
      
      This patch uses new common rss set APIs to replace the old APIs in VF rss
      module and removes those old rss set APIs. The related macros in VF are
      also modified.
      
      Signed-off-by: default avatarJie Wang <wangjie125@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7428d6c9
    • Jie Wang's avatar
      net: hns3: refactor PF rss set APIs with new common rss set APIs · 1813ee52
      Jie Wang authored
      
      
      This patch uses new common rss set APIs to replace the old APIs in PF rss
      module and deletes the old rss set APIs. The related macros are also
      modified.
      
      Signed-off-by: default avatarJie Wang <wangjie125@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      1813ee52
    • Jie Wang's avatar
      net: hns3: create new set of common rss set APIs for PF and VF module · 6de06004
      Jie Wang authored
      
      
      Currently, hns3 PF and VF rss module have two sets of rss set APIs to
      configure rss. There is no need to keep two sets of these same APIs.
      
      So this patch creates new set of common rss set APIs for PF and VF reuse.
      These new APIs will be used to unify old APIs in next patches.
      
      Signed-off-by: default avatarJie Wang <wangjie125@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      6de06004
    • Jie Wang's avatar
      net: hns3: refactor VF rss get APIs with new common rss get APIs · 027733b1
      Jie Wang authored
      
      
      This patch firstly uses new rss parameter struct(hclge_comm_rss_cfg) as
      child member of hclgevf_dev and deletes the original child rss parameter
      member(hclgevf_rss_cfg). All the rss parameter members used in VF rss
      module is modified according to the new hclge_comm_rss_cfg.
      
      Secondly VF rss get APIs are refactored to use new common rss get APIs. The
      old rss get APIs in VF are deleted.
      
      Signed-off-by: default avatarJie Wang <wangjie125@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      027733b1
    • Jie Wang's avatar
      net: hns3: refactor PF rss get APIs with new common rss get APIs · 7347255e
      Jie Wang authored
      
      
      This patch firstly uses new rss parameter struct(hclge_comm_rss_cfg) as
      child member of hclge_dev and deletes the original child rss parameter
      members in vport. All the vport child rss parameter members used in PF rss
      module is modified according to the new hclge_comm_rss_cfg.
      
      Secondly PF rss get APIs are refactored to use new common rss get APIs. The
      old rss get APIs in PF are deleted.
      
      Signed-off-by: default avatarJie Wang <wangjie125@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7347255e
    • Jie Wang's avatar
      net: hns3: create new set of common rss get APIs for PF and VF rss module · 1bfd6682
      Jie Wang authored
      
      
      The PF and VF rss get APIs are almost the same espect the suffixes of API
      names. These same impementions bring double development and bugfix work.
      
      So this patch creates new common rss get APIs for PF and VF rss module.
      Subfunctions called by rss query process are also created(e.g. rss tuple
      conversion APIs).
      
      These new common rss get APIs will be used to replace PF and VF old rss
      APIs in next patches.
      
      Signed-off-by: default avatarJie Wang <wangjie125@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      1bfd6682
    • Jie Wang's avatar
      net: hns3: refactor hclge_comm_send function in PF/VF drivers · 9970308f
      Jie Wang authored
      
      
      Currently, there are two different sets of special command codes in PF and
      VF cmdq modules, this is because VF driver only uses small part of all the
      command codes. In other words, these not used command codes in VF are also
      sepcial command codes theoretically.
      
      So this patch unifes the special command codes and deletes the bool param
      is_pf of hclge_comm_send. All the related functions are refactored
      according to the new hclge_comm_send function prototype.
      
      Signed-off-by: default avatarJie Wang <wangjie125@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9970308f
    • Jie Wang's avatar
      net: hns3: create new rss common structure hclge_comm_rss_cfg · 9667b814
      Jie Wang authored
      
      
      Currently PF stores its rss parameters in vport structure. VF stores rss
      configurations in hclgevf_rss_cfg structure. Actually hns3 rss parameters
      are same beween PF and VF. The two set of rss parameters are redundent and
      may add extra bugfix work.
      
      So this patch creates new common rss parameter struct(hclge_comm_rss_cfg)
      to unify PF and VF rss configurations.
      
      These new structures will be used to unify rss configurations in PF and VF
      rss APIs in next patches.
      
      Signed-off-by: default avatarJie Wang <wangjie125@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9667b814
    • David S. Miller's avatar
      Merge branch 'lan966x-extend-switchdev-and-mdb-support' · c5bcdd82
      David S. Miller authored
      
      
      Horatiu Vultur says:
      
      ====================
      net: lan966x: Extend switchdev with mdb support
      
      This patch series extends lan966x with mdb support by implementing
      the switchdev callbacks: SWITCHDEV_OBJ_ID_PORT_MDB and
      SWITCHDEV_OBJ_ID_HOST_MDB.
      It adds support for both ipv4/ipv6 entries and l2 entries.
      
      v2->v3:
      - rename PGID_FIRST and PGID_LAST to PGID_GP_START and PGID_GP_END
      - don't forget and relearn an entry for the CPU if there are more
        references to the cpu.
      
      v1->v2:
      - rename lan966x_mac_learn_impl to __lan966x_mac_learn
      - rename lan966x_mac_cpu_copy to lan966x_mac_ip_learn
      - fix grammar and typos in comments and commit messages
      - add reference counter for entries that copy frames to CPU
      ====================
      
      Reviewed-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c5bcdd82
    • Horatiu Vultur's avatar
      net: lan966x: Extend switchdev with mdb support · 7aacb894
      Horatiu Vultur authored
      
      
      Extend lan966x driver with mdb support by implementing the switchdev
      calls: SWITCHDEV_OBJ_ID_PORT_MDB and SWITCHDEV_OBJ_ID_HOST_MDB.
      It is allowed to add both ipv4/ipv6 entries and l2 entries. To add
      ipv4/ipv6 entries is not required to use the PGID table while for l2
      entries it is required. The PGID table is much smaller than MAC table
      so only fewer l2 entries can be added.
      
      Signed-off-by: default avatarHoratiu Vultur <horatiu.vultur@microchip.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7aacb894
    • Horatiu Vultur's avatar
      net: lan966x: Add PGID_GP_START and PGID_GP_END · 11b0a277
      Horatiu Vultur authored
      
      
      The first entries in the PGID table are used by the front ports while
      the last entries are used for different purposes like flooding mask,
      copy to CPU, etc. So add these macros to define which entries can be
      used for general purpose.
      
      Signed-off-by: default avatarHoratiu Vultur <horatiu.vultur@microchip.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      11b0a277
    • Horatiu Vultur's avatar
      net: lan966x: Add function lan966x_mac_ip_learn() · fc0c3fe7
      Horatiu Vultur authored
      
      
      Extend mac functionality with the function lan966x_mac_ip_learn. This
      function adds an entry in the MAC table for IP multicast addresses.
      These entries can copy a frame to the CPU but also can forward on the
      front ports.
      This functionality is needed for mdb support. In case the CPU and some
      of the front ports subscribe to an IP multicast address.
      
      Signed-off-by: default avatarHoratiu Vultur <horatiu.vultur@microchip.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      fc0c3fe7
    • David S. Miller's avatar
      Merge branch 'mtk_eth_soc-refactoring-and-clause45' · 2a5ab39b
      David S. Miller authored
      Daniel Golle says:
      
      ====================
      net: ethernet: mtk_eth_soc: refactoring and Clause 45
      
      Rework value and type of mdio read and write functions in mtk_eth_soc
      and generally clean up and unify both functions.
      Then add support to access Clause 45 phy registers, using newly
      introduced helper inline functions added by a patch Russell King has
      suggested in a reply to an earlier version of this series [1].
      
      All three commits are tested on the Bananapi BPi-R64 board having
      MediaTek MT7531BE DSA gigE switch using clause 22 MDIO and
      Ubiquiti UniFi 6 LR access point having Aquantia AQR112C PHY using
      clause 45 MDIO.
      
      [1]: https://lore.kernel.org/netdev/Ycr5Cna76eg2B0An@shell.armlinux.org.uk/
      
      
      
      v11: also address return value of mtk_mdio_busy_wait
      v10: correct order of SoB lines in 2/3, change patch order in series
      v9: improved formatting and Cc missing maintainer
      v8: add patch from Russel King, switch to bitfield helper macros
      v7: remove unneeded variables and order OR-ed call parameters
      v6: further clean up functions and more cleanly separate patches
      v5: fix wrong variable name in first patch covered by follow-up patch
      v4: clean-up return values and types, split into two commits
      v3: return -1 instead of 0xffff on error in _mtk_mdio_write
      v2: use MII_DEVADDR_C45_SHIFT and MII_REGADDR_C45_MASK to extract
          device id and register address. Unify read and write functions to
          have identical types and parameter names where possible as we are
          anyway already replacing both function bodies.
      ====================
      
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      2a5ab39b
    • Daniel Golle's avatar
      net: ethernet: mtk_eth_soc: implement Clause 45 MDIO access · e2e7f6e2
      Daniel Golle authored
      
      
      Implement read and write access to IEEE 802.3 Clause 45 Ethernet
      phy registers while making use of new mdiobus_c45_regad and
      mdiobus_c45_devad helpers.
      
      Tested on the Ubiquiti UniFi 6 LR access point featuring
      MediaTek MT7622BV WiSoC with Aquantia AQR112C.
      
      Signed-off-by: default avatarDaniel Golle <daniel@makrotopia.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e2e7f6e2
    • Russell King (Oracle)'s avatar
      net: mdio: add helpers to extract clause 45 regad and devad fields · c6af53f0
      Russell King (Oracle) authored
      
      
      Add a couple of helpers and definitions to extract the clause 45 regad
      and devad fields from the regnum passed into MDIO drivers.
      
      Tested-by: default avatarDaniel Golle <daniel@makrotopia.org>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarDaniel Golle <daniel@makrotopia.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c6af53f0
    • Daniel Golle's avatar
      net: ethernet: mtk_eth_soc: fix return values and refactor MDIO ops · eda80b24
      Daniel Golle authored
      Instead of returning -1 (-EPERM) when MDIO bus is stuck busy
      while writing or 0xffff if it happens while reading, return the
      appropriate -ETIMEDOUT. Also fix return type to int instead of u32.
      Refactor functions to use bitfield helpers instead of having various
      masking and shifting constants in the code, which also results in the
      register definitions in the header file being more obviously related
      to what is stated in the MediaTek's Reference Manual.
      
      Fixes: 656e7052
      
       ("net-next: mediatek: add support for MT7623 ethernet")
      Signed-off-by: default avatarDaniel Golle <daniel@makrotopia.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      eda80b24
    • M Chetan Kumar's avatar
      Revert "net: wwan: iosm: Keep device at D0 for s2idle case" · ffd32ea6
      M Chetan Kumar authored
      Depending on BIOS configuration IOSM driver exchanges
      protocol required for putting device into D3L2 or D3L1.2.
      
      ipc_pcie_suspend_s2idle() is implemented to put device to D3L1.2.
      
      This patch forces PCI core know this device should stay at D0.
      - pci_save_state()is expensive since it does a lot of slow PCI
      config reads.
      
      The reported issue is not observed on x86 platform. The supurios
      wake on AMD platform needs to be futher debugged with orignal patch
      submitter [1]. Also the impact of adding pci_save_state() needs to be
      assessed by testing it on other platforms.
      
      This reverts commit f4dd5174("net: wwan: iosm: Keep device
      at D0 for s2idle case").
      
      [1] https://lore.kernel.org/all/20211224081914.345292-2-kai.heng.feng@canonical.com/
      
      
      
      Signed-off-by: default avatarM Chetan Kumar <m.chetan.kumar@linux.intel.com>
      Link: https://lore.kernel.org/r/20220104150213.1894-1-m.chetan.kumar@linux.intel.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      ffd32ea6
    • Jakub Kicinski's avatar
      Merge tag 'mac80211-next-for-net-next-2022-01-04' of... · 18343b80
      Jakub Kicinski authored
      Merge tag 'mac80211-next-for-net-next-2022-01-04' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next
      
      Johannes Berg says:
      
      ====================
      Just a few more changes:
       - mac80211: allow non-standard VHT MCSes 10/11
       - mac80211: add sleepable station iterator for drivers
       - nl80211: clarify a comment
       - mac80211: small cleanup to use typed element helpers
      
      * tag 'mac80211-next-for-net-next-2022-01-04' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next:
        mac80211: use ieee80211_bss_get_elem()
        nl80211: clarify comment for mesh PLINK_BLOCKED state
        mac80211: Add stations iterator where the iterator function may sleep
        mac80211: allow non-standard VHT MCS-10/11
      ====================
      
      Link: https://lore.kernel.org/r/20220104153403.69749-1-johannes@sipsolutions.net
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      18343b80
  2. Jan 04, 2022