Commit 9b03c71f authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

rocker: introduce be put/get variants and use it when appropriate

This kills the sparse warnings.
Signed-off-by: default avatarJiri Pirko <jiri@resnulli.us>
Signed-off-by: default avatarScott Feldman <sfeldma@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 86fe8f89
...@@ -648,6 +648,11 @@ static u16 rocker_tlv_get_u16(const struct rocker_tlv *tlv) ...@@ -648,6 +648,11 @@ static u16 rocker_tlv_get_u16(const struct rocker_tlv *tlv)
return *(u16 *) rocker_tlv_data(tlv); return *(u16 *) rocker_tlv_data(tlv);
} }
static __be16 rocker_tlv_get_be16(const struct rocker_tlv *tlv)
{
return *(__be16 *) rocker_tlv_data(tlv);
}
static u32 rocker_tlv_get_u32(const struct rocker_tlv *tlv) static u32 rocker_tlv_get_u32(const struct rocker_tlv *tlv)
{ {
return *(u32 *) rocker_tlv_data(tlv); return *(u32 *) rocker_tlv_data(tlv);
...@@ -726,12 +731,24 @@ static int rocker_tlv_put_u16(struct rocker_desc_info *desc_info, ...@@ -726,12 +731,24 @@ static int rocker_tlv_put_u16(struct rocker_desc_info *desc_info,
return rocker_tlv_put(desc_info, attrtype, sizeof(u16), &value); return rocker_tlv_put(desc_info, attrtype, sizeof(u16), &value);
} }
static int rocker_tlv_put_be16(struct rocker_desc_info *desc_info,
int attrtype, __be16 value)
{
return rocker_tlv_put(desc_info, attrtype, sizeof(__be16), &value);
}
static int rocker_tlv_put_u32(struct rocker_desc_info *desc_info, static int rocker_tlv_put_u32(struct rocker_desc_info *desc_info,
int attrtype, u32 value) int attrtype, u32 value)
{ {
return rocker_tlv_put(desc_info, attrtype, sizeof(u32), &value); return rocker_tlv_put(desc_info, attrtype, sizeof(u32), &value);
} }
static int rocker_tlv_put_be32(struct rocker_desc_info *desc_info,
int attrtype, __be32 value)
{
return rocker_tlv_put(desc_info, attrtype, sizeof(__be32), &value);
}
static int rocker_tlv_put_u64(struct rocker_desc_info *desc_info, static int rocker_tlv_put_u64(struct rocker_desc_info *desc_info,
int attrtype, u64 value) int attrtype, u64 value)
{ {
...@@ -1343,7 +1360,7 @@ static int rocker_event_mac_vlan_seen(struct rocker *rocker, ...@@ -1343,7 +1360,7 @@ static int rocker_event_mac_vlan_seen(struct rocker *rocker,
port_number = port_number =
rocker_tlv_get_u32(attrs[ROCKER_TLV_EVENT_MAC_VLAN_LPORT]) - 1; rocker_tlv_get_u32(attrs[ROCKER_TLV_EVENT_MAC_VLAN_LPORT]) - 1;
addr = rocker_tlv_data(attrs[ROCKER_TLV_EVENT_MAC_VLAN_MAC]); addr = rocker_tlv_data(attrs[ROCKER_TLV_EVENT_MAC_VLAN_MAC]);
vlan_id = rocker_tlv_get_u16(attrs[ROCKER_TLV_EVENT_MAC_VLAN_VLAN_ID]); vlan_id = rocker_tlv_get_be16(attrs[ROCKER_TLV_EVENT_MAC_VLAN_VLAN_ID]);
if (port_number >= rocker->port_count) if (port_number >= rocker->port_count)
return -EINVAL; return -EINVAL;
...@@ -1717,17 +1734,17 @@ static int rocker_cmd_flow_tbl_add_vlan(struct rocker_desc_info *desc_info, ...@@ -1717,17 +1734,17 @@ static int rocker_cmd_flow_tbl_add_vlan(struct rocker_desc_info *desc_info,
if (rocker_tlv_put_u32(desc_info, ROCKER_TLV_OF_DPA_IN_LPORT, if (rocker_tlv_put_u32(desc_info, ROCKER_TLV_OF_DPA_IN_LPORT,
entry->key.vlan.in_lport)) entry->key.vlan.in_lport))
return -EMSGSIZE; return -EMSGSIZE;
if (rocker_tlv_put_u16(desc_info, ROCKER_TLV_OF_DPA_VLAN_ID, if (rocker_tlv_put_be16(desc_info, ROCKER_TLV_OF_DPA_VLAN_ID,
entry->key.vlan.vlan_id)) entry->key.vlan.vlan_id))
return -EMSGSIZE; return -EMSGSIZE;
if (rocker_tlv_put_u16(desc_info, ROCKER_TLV_OF_DPA_VLAN_ID_MASK, if (rocker_tlv_put_be16(desc_info, ROCKER_TLV_OF_DPA_VLAN_ID_MASK,
entry->key.vlan.vlan_id_mask)) entry->key.vlan.vlan_id_mask))
return -EMSGSIZE; return -EMSGSIZE;
if (rocker_tlv_put_u16(desc_info, ROCKER_TLV_OF_DPA_GOTO_TABLE_ID, if (rocker_tlv_put_u16(desc_info, ROCKER_TLV_OF_DPA_GOTO_TABLE_ID,
entry->key.vlan.goto_tbl)) entry->key.vlan.goto_tbl))
return -EMSGSIZE; return -EMSGSIZE;
if (entry->key.vlan.untagged && if (entry->key.vlan.untagged &&
rocker_tlv_put_u16(desc_info, ROCKER_TLV_OF_DPA_NEW_VLAN_ID, rocker_tlv_put_be16(desc_info, ROCKER_TLV_OF_DPA_NEW_VLAN_ID,
entry->key.vlan.new_vlan_id)) entry->key.vlan.new_vlan_id))
return -EMSGSIZE; return -EMSGSIZE;
...@@ -1743,7 +1760,7 @@ static int rocker_cmd_flow_tbl_add_term_mac(struct rocker_desc_info *desc_info, ...@@ -1743,7 +1760,7 @@ static int rocker_cmd_flow_tbl_add_term_mac(struct rocker_desc_info *desc_info,
if (rocker_tlv_put_u32(desc_info, ROCKER_TLV_OF_DPA_IN_LPORT_MASK, if (rocker_tlv_put_u32(desc_info, ROCKER_TLV_OF_DPA_IN_LPORT_MASK,
entry->key.term_mac.in_lport_mask)) entry->key.term_mac.in_lport_mask))
return -EMSGSIZE; return -EMSGSIZE;
if (rocker_tlv_put_u16(desc_info, ROCKER_TLV_OF_DPA_ETHERTYPE, if (rocker_tlv_put_be16(desc_info, ROCKER_TLV_OF_DPA_ETHERTYPE,
entry->key.term_mac.eth_type)) entry->key.term_mac.eth_type))
return -EMSGSIZE; return -EMSGSIZE;
if (rocker_tlv_put(desc_info, ROCKER_TLV_OF_DPA_DST_MAC, if (rocker_tlv_put(desc_info, ROCKER_TLV_OF_DPA_DST_MAC,
...@@ -1752,10 +1769,10 @@ static int rocker_cmd_flow_tbl_add_term_mac(struct rocker_desc_info *desc_info, ...@@ -1752,10 +1769,10 @@ static int rocker_cmd_flow_tbl_add_term_mac(struct rocker_desc_info *desc_info,
if (rocker_tlv_put(desc_info, ROCKER_TLV_OF_DPA_DST_MAC_MASK, if (rocker_tlv_put(desc_info, ROCKER_TLV_OF_DPA_DST_MAC_MASK,
ETH_ALEN, entry->key.term_mac.eth_dst_mask)) ETH_ALEN, entry->key.term_mac.eth_dst_mask))
return -EMSGSIZE; return -EMSGSIZE;
if (rocker_tlv_put_u16(desc_info, ROCKER_TLV_OF_DPA_VLAN_ID, if (rocker_tlv_put_be16(desc_info, ROCKER_TLV_OF_DPA_VLAN_ID,
entry->key.term_mac.vlan_id)) entry->key.term_mac.vlan_id))
return -EMSGSIZE; return -EMSGSIZE;
if (rocker_tlv_put_u16(desc_info, ROCKER_TLV_OF_DPA_VLAN_ID_MASK, if (rocker_tlv_put_be16(desc_info, ROCKER_TLV_OF_DPA_VLAN_ID_MASK,
entry->key.term_mac.vlan_id_mask)) entry->key.term_mac.vlan_id_mask))
return -EMSGSIZE; return -EMSGSIZE;
if (rocker_tlv_put_u16(desc_info, ROCKER_TLV_OF_DPA_GOTO_TABLE_ID, if (rocker_tlv_put_u16(desc_info, ROCKER_TLV_OF_DPA_GOTO_TABLE_ID,
...@@ -1773,13 +1790,13 @@ static int ...@@ -1773,13 +1790,13 @@ static int
rocker_cmd_flow_tbl_add_ucast_routing(struct rocker_desc_info *desc_info, rocker_cmd_flow_tbl_add_ucast_routing(struct rocker_desc_info *desc_info,
struct rocker_flow_tbl_entry *entry) struct rocker_flow_tbl_entry *entry)
{ {
if (rocker_tlv_put_u16(desc_info, ROCKER_TLV_OF_DPA_ETHERTYPE, if (rocker_tlv_put_be16(desc_info, ROCKER_TLV_OF_DPA_ETHERTYPE,
entry->key.ucast_routing.eth_type)) entry->key.ucast_routing.eth_type))
return -EMSGSIZE; return -EMSGSIZE;
if (rocker_tlv_put_u32(desc_info, ROCKER_TLV_OF_DPA_DST_IP, if (rocker_tlv_put_be32(desc_info, ROCKER_TLV_OF_DPA_DST_IP,
entry->key.ucast_routing.dst4)) entry->key.ucast_routing.dst4))
return -EMSGSIZE; return -EMSGSIZE;
if (rocker_tlv_put_u32(desc_info, ROCKER_TLV_OF_DPA_DST_IP_MASK, if (rocker_tlv_put_be32(desc_info, ROCKER_TLV_OF_DPA_DST_IP_MASK,
entry->key.ucast_routing.dst4_mask)) entry->key.ucast_routing.dst4_mask))
return -EMSGSIZE; return -EMSGSIZE;
if (rocker_tlv_put_u16(desc_info, ROCKER_TLV_OF_DPA_GOTO_TABLE_ID, if (rocker_tlv_put_u16(desc_info, ROCKER_TLV_OF_DPA_GOTO_TABLE_ID,
...@@ -1804,7 +1821,7 @@ static int rocker_cmd_flow_tbl_add_bridge(struct rocker_desc_info *desc_info, ...@@ -1804,7 +1821,7 @@ static int rocker_cmd_flow_tbl_add_bridge(struct rocker_desc_info *desc_info,
ETH_ALEN, entry->key.bridge.eth_dst_mask)) ETH_ALEN, entry->key.bridge.eth_dst_mask))
return -EMSGSIZE; return -EMSGSIZE;
if (entry->key.bridge.vlan_id && if (entry->key.bridge.vlan_id &&
rocker_tlv_put_u16(desc_info, ROCKER_TLV_OF_DPA_VLAN_ID, rocker_tlv_put_be16(desc_info, ROCKER_TLV_OF_DPA_VLAN_ID,
entry->key.bridge.vlan_id)) entry->key.bridge.vlan_id))
return -EMSGSIZE; return -EMSGSIZE;
if (entry->key.bridge.tunnel_id && if (entry->key.bridge.tunnel_id &&
...@@ -1846,13 +1863,13 @@ static int rocker_cmd_flow_tbl_add_acl(struct rocker_desc_info *desc_info, ...@@ -1846,13 +1863,13 @@ static int rocker_cmd_flow_tbl_add_acl(struct rocker_desc_info *desc_info,
if (rocker_tlv_put(desc_info, ROCKER_TLV_OF_DPA_DST_MAC_MASK, if (rocker_tlv_put(desc_info, ROCKER_TLV_OF_DPA_DST_MAC_MASK,
ETH_ALEN, entry->key.acl.eth_dst_mask)) ETH_ALEN, entry->key.acl.eth_dst_mask))
return -EMSGSIZE; return -EMSGSIZE;
if (rocker_tlv_put_u16(desc_info, ROCKER_TLV_OF_DPA_ETHERTYPE, if (rocker_tlv_put_be16(desc_info, ROCKER_TLV_OF_DPA_ETHERTYPE,
entry->key.acl.eth_type)) entry->key.acl.eth_type))
return -EMSGSIZE; return -EMSGSIZE;
if (rocker_tlv_put_u16(desc_info, ROCKER_TLV_OF_DPA_VLAN_ID, if (rocker_tlv_put_be16(desc_info, ROCKER_TLV_OF_DPA_VLAN_ID,
entry->key.acl.vlan_id)) entry->key.acl.vlan_id))
return -EMSGSIZE; return -EMSGSIZE;
if (rocker_tlv_put_u16(desc_info, ROCKER_TLV_OF_DPA_VLAN_ID_MASK, if (rocker_tlv_put_be16(desc_info, ROCKER_TLV_OF_DPA_VLAN_ID_MASK,
entry->key.acl.vlan_id_mask)) entry->key.acl.vlan_id_mask))
return -EMSGSIZE; return -EMSGSIZE;
...@@ -2002,7 +2019,7 @@ rocker_cmd_group_tbl_add_l2_rewrite(struct rocker_desc_info *desc_info, ...@@ -2002,7 +2019,7 @@ rocker_cmd_group_tbl_add_l2_rewrite(struct rocker_desc_info *desc_info,
ETH_ALEN, entry->l2_rewrite.eth_dst)) ETH_ALEN, entry->l2_rewrite.eth_dst))
return -EMSGSIZE; return -EMSGSIZE;
if (entry->l2_rewrite.vlan_id && if (entry->l2_rewrite.vlan_id &&
rocker_tlv_put_u16(desc_info, ROCKER_TLV_OF_DPA_VLAN_ID, rocker_tlv_put_be16(desc_info, ROCKER_TLV_OF_DPA_VLAN_ID,
entry->l2_rewrite.vlan_id)) entry->l2_rewrite.vlan_id))
return -EMSGSIZE; return -EMSGSIZE;
...@@ -2048,7 +2065,7 @@ rocker_cmd_group_tbl_add_l3_unicast(struct rocker_desc_info *desc_info, ...@@ -2048,7 +2065,7 @@ rocker_cmd_group_tbl_add_l3_unicast(struct rocker_desc_info *desc_info,
ETH_ALEN, entry->l3_unicast.eth_dst)) ETH_ALEN, entry->l3_unicast.eth_dst))
return -EMSGSIZE; return -EMSGSIZE;
if (entry->l3_unicast.vlan_id && if (entry->l3_unicast.vlan_id &&
rocker_tlv_put_u16(desc_info, ROCKER_TLV_OF_DPA_VLAN_ID, rocker_tlv_put_be16(desc_info, ROCKER_TLV_OF_DPA_VLAN_ID,
entry->l3_unicast.vlan_id)) entry->l3_unicast.vlan_id))
return -EMSGSIZE; return -EMSGSIZE;
if (rocker_tlv_put_u8(desc_info, ROCKER_TLV_OF_DPA_TTL_CHECK, if (rocker_tlv_put_u8(desc_info, ROCKER_TLV_OF_DPA_TTL_CHECK,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment