Skip to content

Commit c983e32

Browse files
Andre GuedesJeff Kirsher
authored andcommitted
igc: Change byte order in struct igc_nfc_filter
Every time we access the 'etype' and 'vlan_tci' fields from struct igc_nfc_filter to enable or disable filters in hardware we have to convert them from big endian to host order so it makes more sense to simply have these fields in host order. The byte order conversion should take place in igc_ethtool_get_nfc_ rule() and igc_ethtool_add_nfc_rule(), which are called by .get_rxnfc and .set_rxnfc ethtool ops, since ethtool subsystem is the one who deals with them in big endian order. Signed-off-by: Andre Guedes <[email protected]> Tested-by: Aaron Brown <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 97700bc commit c983e32

File tree

2 files changed

+13
-22
lines changed

2 files changed

+13
-22
lines changed

drivers/net/ethernet/intel/igc/igc.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -452,16 +452,10 @@ enum igc_filter_match_flags {
452452
IGC_FILTER_FLAG_DST_MAC_ADDR = 0x8,
453453
};
454454

455-
/* RX network flow classification data structure */
456455
struct igc_nfc_filter {
457-
/* Byte layout in order, all values with MSB first:
458-
* match_flags - 1 byte
459-
* etype - 2 bytes
460-
* vlan_tci - 2 bytes
461-
*/
462456
u8 match_flags;
463-
__be16 etype;
464-
__be16 vlan_tci;
457+
u16 etype;
458+
u16 vlan_tci;
465459
u8 src_addr[ETH_ALEN];
466460
u8 dst_addr[ETH_ALEN];
467461
};

drivers/net/ethernet/intel/igc/igc_ethtool.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -954,13 +954,13 @@ static int igc_ethtool_get_nfc_rule(struct igc_adapter *adapter,
954954
fsp->ring_cookie = rule->action;
955955

956956
if (rule->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE) {
957-
fsp->h_u.ether_spec.h_proto = rule->filter.etype;
957+
fsp->h_u.ether_spec.h_proto = htons(rule->filter.etype);
958958
fsp->m_u.ether_spec.h_proto = ETHER_TYPE_FULL_MASK;
959959
}
960960

961961
if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) {
962962
fsp->flow_type |= FLOW_EXT;
963-
fsp->h_ext.vlan_tci = rule->filter.vlan_tci;
963+
fsp->h_ext.vlan_tci = htons(rule->filter.vlan_tci);
964964
fsp->m_ext.vlan_tci = htons(VLAN_PRIO_MASK);
965965
}
966966

@@ -1183,9 +1183,8 @@ int igc_enable_nfc_rule(struct igc_adapter *adapter,
11831183
int err = -EINVAL;
11841184

11851185
if (rule->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE) {
1186-
u16 etype = ntohs(rule->filter.etype);
1187-
1188-
err = igc_add_etype_filter(adapter, etype, rule->action);
1186+
err = igc_add_etype_filter(adapter, rule->filter.etype,
1187+
rule->action);
11891188
if (err)
11901189
return err;
11911190
}
@@ -1205,8 +1204,9 @@ int igc_enable_nfc_rule(struct igc_adapter *adapter,
12051204
}
12061205

12071206
if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) {
1208-
int prio = (ntohs(rule->filter.vlan_tci) & VLAN_PRIO_MASK) >>
1207+
int prio = (rule->filter.vlan_tci & VLAN_PRIO_MASK) >>
12091208
VLAN_PRIO_SHIFT;
1209+
12101210
err = igc_add_vlan_prio_filter(adapter, prio, rule->action);
12111211
if (err)
12121212
return err;
@@ -1218,14 +1218,11 @@ int igc_enable_nfc_rule(struct igc_adapter *adapter,
12181218
int igc_disable_nfc_rule(struct igc_adapter *adapter,
12191219
const struct igc_nfc_rule *rule)
12201220
{
1221-
if (rule->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE) {
1222-
u16 etype = ntohs(rule->filter.etype);
1223-
1224-
igc_del_etype_filter(adapter, etype);
1225-
}
1221+
if (rule->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE)
1222+
igc_del_etype_filter(adapter, rule->filter.etype);
12261223

12271224
if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) {
1228-
int prio = (ntohs(rule->filter.vlan_tci) & VLAN_PRIO_MASK) >>
1225+
int prio = (rule->filter.vlan_tci & VLAN_PRIO_MASK) >>
12291226
VLAN_PRIO_SHIFT;
12301227
igc_del_vlan_prio_filter(adapter, prio);
12311228
}
@@ -1325,7 +1322,7 @@ static int igc_ethtool_add_nfc_rule(struct igc_adapter *adapter,
13251322
return -ENOMEM;
13261323

13271324
if (fsp->m_u.ether_spec.h_proto == ETHER_TYPE_FULL_MASK) {
1328-
rule->filter.etype = fsp->h_u.ether_spec.h_proto;
1325+
rule->filter.etype = ntohs(fsp->h_u.ether_spec.h_proto);
13291326
rule->filter.match_flags = IGC_FILTER_FLAG_ETHER_TYPE;
13301327
}
13311328

@@ -1357,7 +1354,7 @@ static int igc_ethtool_add_nfc_rule(struct igc_adapter *adapter,
13571354
err = -EOPNOTSUPP;
13581355
goto err_out;
13591356
}
1360-
rule->filter.vlan_tci = fsp->h_ext.vlan_tci;
1357+
rule->filter.vlan_tci = ntohs(fsp->h_ext.vlan_tci);
13611358
rule->filter.match_flags |= IGC_FILTER_FLAG_VLAN_TCI;
13621359
}
13631360

0 commit comments

Comments
 (0)