History

Revert "net: ethtool: Avoid thousands of -Wflex-array-member-not-at-end warnings"

This reverts commit 3bd9b9abdf1563a22041b7255baea6d449902f1a. We cannot use the new tagged struct group because it throws C++ errors even under "extern C".

Kees Cook committed 1 year ago

Commit 1cfb5e51 parent 920efe39 files · +22 −26Browse files

Unified · Split

9 files
  1. drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +3 −3
  2. drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c +2 −2
  3. drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c +1 −1
  4. drivers/net/ethernet/cisco/enic/enic_ethtool.c +1 −1
  5. drivers/net/ethernet/qlogic/qede/qede_ethtool.c +2 −2
  6. include/linux/ethtool.h +1 −1
  7. net/ethtool/ioctl.c +1 −1
  8. net/ethtool/linkinfo.c +4 −4
  9. net/ethtool/linkmodes.c +7 −11
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c+3−3
@@ -2780,7 +2780,7 @@ u32 bnxt_fw_to_ethtool_speed(u16 fw_link_speed) · 2779 unmodified lines
2780static void bnxt_get_default_speeds(struct ethtool_link_ksettings *lk_ksettings,2780static void bnxt_get_default_speeds(struct ethtool_link_ksettings *lk_ksettings,
2781 struct bnxt_link_info *link_info)2781 struct bnxt_link_info *link_info)
2782{2782{
2783 struct ethtool_link_settings_hdr *base = &lk_ksettings->base;2783 struct ethtool_link_settings *base = &lk_ksettings->base;
2784 2784
2785 if (link_info->link_state == BNXT_LINK_STATE_UP) {2785 if (link_info->link_state == BNXT_LINK_STATE_UP) {
2786 base->speed = bnxt_fw_to_ethtool_speed(link_info->link_speed);2786 base->speed = bnxt_fw_to_ethtool_speed(link_info->link_speed);
@@ -2799,7 +2799,7 @@ static void bnxt_get_default_speeds(struct ethtool_link_ksettings *lk_ksettings, · 12 unmodified lines
2799static int bnxt_get_link_ksettings(struct net_device *dev,2799static int bnxt_get_link_ksettings(struct net_device *dev,
2800 struct ethtool_link_ksettings *lk_ksettings)2800 struct ethtool_link_ksettings *lk_ksettings)
2801{2801{
2802 struct ethtool_link_settings_hdr *base = &lk_ksettings->base;2802 struct ethtool_link_settings *base = &lk_ksettings->base;
2803 enum ethtool_link_mode_bit_indices link_mode;2803 enum ethtool_link_mode_bit_indices link_mode;
2804 struct bnxt *bp = netdev_priv(dev);2804 struct bnxt *bp = netdev_priv(dev);
2805 struct bnxt_link_info *link_info;2805 struct bnxt_link_info *link_info;
@@ -3022,9 +3022,9 @@ u16 bnxt_get_fw_auto_link_speeds(const unsigned long *mode) · 216 unmodified lines
3022static int bnxt_set_link_ksettings(struct net_device *dev,3022static int bnxt_set_link_ksettings(struct net_device *dev,
3023 const struct ethtool_link_ksettings *lk_ksettings)3023 const struct ethtool_link_ksettings *lk_ksettings)
3024{3024{
3025 const struct ethtool_link_settings_hdr *base = &lk_ksettings->base;
3026 struct bnxt *bp = netdev_priv(dev);3025 struct bnxt *bp = netdev_priv(dev);
3027 struct bnxt_link_info *link_info = &bp->link_info;3026 struct bnxt_link_info *link_info = &bp->link_info;
3027 const struct ethtool_link_settings *base = &lk_ksettings->base;
3028 bool set_pause = false;3028 bool set_pause = false;
3029 u32 speed, lanes = 0;3029 u32 speed, lanes = 0;
3030 int rc = 0;3030 int rc = 0;
drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c+2−2
@@ -662,8 +662,8 @@ static unsigned int lmm_to_fw_caps(const unsigned long *link_mode_mask) · 661 unmodified lines
662static int get_link_ksettings(struct net_device *dev,662static int get_link_ksettings(struct net_device *dev,
663 struct ethtool_link_ksettings *link_ksettings)663 struct ethtool_link_ksettings *link_ksettings)
664{664{
665 struct ethtool_link_settings_hdr *base = &link_ksettings->base;
666 struct port_info *pi = netdev_priv(dev);665 struct port_info *pi = netdev_priv(dev);
666 struct ethtool_link_settings *base = &link_ksettings->base;
667 667
668 /* For the nonce, the Firmware doesn't send up Port State changes668 /* For the nonce, the Firmware doesn't send up Port State changes
669 * when the Virtual Interface attached to the Port is down. So669 * when the Virtual Interface attached to the Port is down. So
@@ -717,9 +717,9 @@ static int get_link_ksettings(struct net_device *dev, · 47 unmodified lines
717static int set_link_ksettings(struct net_device *dev,717static int set_link_ksettings(struct net_device *dev,
718 const struct ethtool_link_ksettings *link_ksettings)718 const struct ethtool_link_ksettings *link_ksettings)
719{719{
720 const struct ethtool_link_settings_hdr *base = &link_ksettings->base;
721 struct port_info *pi = netdev_priv(dev);720 struct port_info *pi = netdev_priv(dev);
722 struct link_config *lc = &pi->link_cfg;721 struct link_config *lc = &pi->link_cfg;
722 const struct ethtool_link_settings *base = &link_ksettings->base;
723 struct link_config old_lc;723 struct link_config old_lc;
724 unsigned int fw_caps;724 unsigned int fw_caps;
725 int ret = 0;725 int ret = 0;
drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c+1−1
@@ -1436,8 +1436,8 @@ static void fw_caps_to_lmm(enum fw_port_type port_type, · 1435 unmodified lines
1436static int cxgb4vf_get_link_ksettings(struct net_device *dev,1436static int cxgb4vf_get_link_ksettings(struct net_device *dev,
1437 struct ethtool_link_ksettings *link_ksettings)1437 struct ethtool_link_ksettings *link_ksettings)
1438{1438{
1439 struct ethtool_link_settings_hdr *base = &link_ksettings->base;
1440 struct port_info *pi = netdev_priv(dev);1439 struct port_info *pi = netdev_priv(dev);
1440 struct ethtool_link_settings *base = &link_ksettings->base;
1441 1441
1442 /* For the nonce, the Firmware doesn't send up Port State changes1442 /* For the nonce, the Firmware doesn't send up Port State changes
1443 * when the Virtual Interface attached to the Port is down. So1443 * when the Virtual Interface attached to the Port is down. So
drivers/net/ethernet/cisco/enic/enic_ethtool.c+1−1
@@ -129,8 +129,8 @@ static void enic_intr_coal_set_rx(struct enic *enic, u32 timer) · 128 unmodified lines
129static int enic_get_ksettings(struct net_device *netdev,129static int enic_get_ksettings(struct net_device *netdev,
130 struct ethtool_link_ksettings *ecmd)130 struct ethtool_link_ksettings *ecmd)
131{131{
132 struct ethtool_link_settings_hdr *base = &ecmd->base;
133 struct enic *enic = netdev_priv(netdev);132 struct enic *enic = netdev_priv(netdev);
133 struct ethtool_link_settings *base = &ecmd->base;
134 134
135 ethtool_link_ksettings_add_link_mode(ecmd, supported,135 ethtool_link_ksettings_add_link_mode(ecmd, supported,
136 10000baseT_Full);136 10000baseT_Full);
drivers/net/ethernet/qlogic/qede/qede_ethtool.c+2−2
@@ -504,7 +504,7 @@ static int qede_get_link_ksettings(struct net_device *dev, · 503 unmodified lines
504 struct ethtool_link_ksettings *cmd)504 struct ethtool_link_ksettings *cmd)
505{505{
506 typeof(cmd->link_modes) *link_modes = &cmd->link_modes;506 typeof(cmd->link_modes) *link_modes = &cmd->link_modes;
507 struct ethtool_link_settings_hdr *base = &cmd->base;507 struct ethtool_link_settings *base = &cmd->base;
508 struct qede_dev *edev = netdev_priv(dev);508 struct qede_dev *edev = netdev_priv(dev);
509 struct qed_link_output current_link;509 struct qed_link_output current_link;
510 510
@@ -537,7 +537,7 @@ static int qede_get_link_ksettings(struct net_device *dev, · 26 unmodified lines
537static int qede_set_link_ksettings(struct net_device *dev,537static int qede_set_link_ksettings(struct net_device *dev,
538 const struct ethtool_link_ksettings *cmd)538 const struct ethtool_link_ksettings *cmd)
539{539{
540 const struct ethtool_link_settings_hdr *base = &cmd->base;540 const struct ethtool_link_settings *base = &cmd->base;
541 const struct ethtool_forced_speed_map *map;541 const struct ethtool_forced_speed_map *map;
542 struct qede_dev *edev = netdev_priv(dev);542 struct qede_dev *edev = netdev_priv(dev);
543 struct qed_link_output current_link;543 struct qed_link_output current_link;
include/linux/ethtool.h+1−1
@@ -211,7 +211,7 @@ void ethtool_rxfh_context_lost(struct net_device *dev, u32 context_id); · 210 unmodified lines
211 * fields, but they are allowed to overwrite them (will be ignored).211 * fields, but they are allowed to overwrite them (will be ignored).
212 */212 */
213struct ethtool_link_ksettings {213struct ethtool_link_ksettings {
214 struct ethtool_link_settings_hdr base;214 struct ethtool_link_settings base;
215 struct {215 struct {
216 __ETHTOOL_DECLARE_LINK_MODE_MASK(supported);216 __ETHTOOL_DECLARE_LINK_MODE_MASK(supported);
217 __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising);217 __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising);
net/ethtool/ioctl.c+1−1
@@ -425,7 +425,7 @@ convert_link_ksettings_to_legacy_settings( · 424 unmodified lines
425 425
426/* layout of the struct passed from/to userland */426/* layout of the struct passed from/to userland */
427struct ethtool_link_usettings {427struct ethtool_link_usettings {
428 struct ethtool_link_settings_hdr base;428 struct ethtool_link_settings base;
429 struct {429 struct {
430 __u32 supported[__ETHTOOL_LINK_MODE_MASK_NU32];430 __u32 supported[__ETHTOOL_LINK_MODE_MASK_NU32];
431 __u32 advertising[__ETHTOOL_LINK_MODE_MASK_NU32];431 __u32 advertising[__ETHTOOL_LINK_MODE_MASK_NU32];
net/ethtool/linkinfo.c+4−4
@@ -8,9 +8,9 @@ struct linkinfo_req_info { · 7 unmodified lines
8};8};
9 9
10struct linkinfo_reply_data {10struct linkinfo_reply_data {
11 struct ethnl_reply_data base;11 struct ethnl_reply_data base;
12 struct ethtool_link_ksettings ksettings;12 struct ethtool_link_ksettings ksettings;
13 struct ethtool_link_settings_hdr *lsettings;13 struct ethtool_link_settings *lsettings;
14};14};
15 15
16#define LINKINFO_REPDATA(__reply_base) \16#define LINKINFO_REPDATA(__reply_base) \
@@ -98,7 +98,7 @@ static int · 81 unmodified lines
98ethnl_set_linkinfo(struct ethnl_req_info *req_info, struct genl_info *info)98ethnl_set_linkinfo(struct ethnl_req_info *req_info, struct genl_info *info)
99{99{
100 struct ethtool_link_ksettings ksettings = {};100 struct ethtool_link_ksettings ksettings = {};
101 struct ethtool_link_settings_hdr *lsettings;101 struct ethtool_link_settings *lsettings;
102 struct net_device *dev = req_info->dev;102 struct net_device *dev = req_info->dev;
103 struct nlattr **tb = info->attrs;103 struct nlattr **tb = info->attrs;
104 bool mod = false;104 bool mod = false;
net/ethtool/linkmodes.c+7−11
@@ -11,10 +11,10 @@ struct linkmodes_req_info { · 10 unmodified lines
11};11};
12 12
13struct linkmodes_reply_data {13struct linkmodes_reply_data {
14 struct ethnl_reply_data base;14 struct ethnl_reply_data base;
15 struct ethtool_link_ksettings ksettings;15 struct ethtool_link_ksettings ksettings;
16 struct ethtool_link_settings_hdr *lsettings;16 struct ethtool_link_settings *lsettings;
17 bool peer_empty;17 bool peer_empty;
18};18};
19 19
20#define LINKMODES_REPDATA(__reply_base) \20#define LINKMODES_REPDATA(__reply_base) \
@@ -62,12 +62,10 @@ static int linkmodes_reply_size(const struct ethnl_req_info *req_base, · 41 unmodified lines
62{62{
63 const struct linkmodes_reply_data *data = LINKMODES_REPDATA(reply_base);63 const struct linkmodes_reply_data *data = LINKMODES_REPDATA(reply_base);
64 const struct ethtool_link_ksettings *ksettings = &data->ksettings;64 const struct ethtool_link_ksettings *ksettings = &data->ksettings;
65 const struct ethtool_link_settings *lsettings = &ksettings->base;
65 bool compact = req_base->flags & ETHTOOL_FLAG_COMPACT_BITSETS;66 bool compact = req_base->flags & ETHTOOL_FLAG_COMPACT_BITSETS;
66 const struct ethtool_link_settings_hdr *lsettings;
67 int len, ret;67 int len, ret;
68 68
69 lsettings = &ksettings->base;
70
71 len = nla_total_size(sizeof(u8)) /* LINKMODES_AUTONEG */69 len = nla_total_size(sizeof(u8)) /* LINKMODES_AUTONEG */
72 + nla_total_size(sizeof(u32)) /* LINKMODES_SPEED */70 + nla_total_size(sizeof(u32)) /* LINKMODES_SPEED */
73 + nla_total_size(sizeof(u32)) /* LINKMODES_LANES */71 + nla_total_size(sizeof(u32)) /* LINKMODES_LANES */
@@ -105,12 +103,10 @@ static int linkmodes_fill_reply(struct sk_buff *skb, · 31 unmodified lines
105{103{
106 const struct linkmodes_reply_data *data = LINKMODES_REPDATA(reply_base);104 const struct linkmodes_reply_data *data = LINKMODES_REPDATA(reply_base);
107 const struct ethtool_link_ksettings *ksettings = &data->ksettings;105 const struct ethtool_link_ksettings *ksettings = &data->ksettings;
106 const struct ethtool_link_settings *lsettings = &ksettings->base;
108 bool compact = req_base->flags & ETHTOOL_FLAG_COMPACT_BITSETS;107 bool compact = req_base->flags & ETHTOOL_FLAG_COMPACT_BITSETS;
109 const struct ethtool_link_settings_hdr *lsettings;
110 int ret;108 int ret;
111 109
112 lsettings = &ksettings->base;
113
114 if (nla_put_u8(skb, ETHTOOL_A_LINKMODES_AUTONEG, lsettings->autoneg))110 if (nla_put_u8(skb, ETHTOOL_A_LINKMODES_AUTONEG, lsettings->autoneg))
115 return -EMSGSIZE;111 return -EMSGSIZE;
116 112
@@ -241,7 +237,7 @@ static int ethnl_update_linkmodes(struct genl_info *info, struct nlattr **tb, · 124 unmodified lines
241 struct ethtool_link_ksettings *ksettings,237 struct ethtool_link_ksettings *ksettings,
242 bool *mod, const struct net_device *dev)238 bool *mod, const struct net_device *dev)
243{239{
244 struct ethtool_link_settings_hdr *lsettings = &ksettings->base;240 struct ethtool_link_settings *lsettings = &ksettings->base;
245 bool req_speed, req_lanes, req_duplex;241 bool req_speed, req_lanes, req_duplex;
246 const struct nlattr *master_slave_cfg, *lanes_cfg;242 const struct nlattr *master_slave_cfg, *lanes_cfg;
247 int ret;243 int ret;