nfp: flower: update nfp_tun_neigh structs
Prepare for more rework in following patches by updating the existing nfp_neigh_structs. The update allows for the same headers to be used for both old and new firmware, with a slight length adjustment when sending the control message to the firmware. Signed-off-by: Louis Peens <louis.peens@corigine.com> Signed-off-by: Yinjun Zhang <yinjun.zhang@corigine.com> Signed-off-by: Simon Horman <simon.horman@corigine.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
9d5447ed44
commit
9ee7c42183
@ -111,47 +111,55 @@ struct nfp_fl_tunnel_offloads {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct nfp_tun_neigh - neighbour/route entry on the NFP
|
* struct nfp_tun_neigh - basic neighbour data
|
||||||
* @dst_ipv4: Destination IPv4 address
|
|
||||||
* @src_ipv4: Source IPv4 address
|
|
||||||
* @dst_addr: Destination MAC address
|
* @dst_addr: Destination MAC address
|
||||||
* @src_addr: Source MAC address
|
* @src_addr: Source MAC address
|
||||||
* @port_id: NFP port to output packet on - associated with source IPv4
|
* @port_id: NFP port to output packet on - associated with source IPv4
|
||||||
|
*/
|
||||||
|
struct nfp_tun_neigh {
|
||||||
|
u8 dst_addr[ETH_ALEN];
|
||||||
|
u8 src_addr[ETH_ALEN];
|
||||||
|
__be32 port_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct nfp_tun_neigh_ext - extended neighbour data
|
||||||
* @vlan_tpid: VLAN_TPID match field
|
* @vlan_tpid: VLAN_TPID match field
|
||||||
* @vlan_tci: VLAN_TCI match field
|
* @vlan_tci: VLAN_TCI match field
|
||||||
* @host_ctx: Host context ID to be saved here
|
* @host_ctx: Host context ID to be saved here
|
||||||
*/
|
*/
|
||||||
struct nfp_tun_neigh {
|
struct nfp_tun_neigh_ext {
|
||||||
__be32 dst_ipv4;
|
|
||||||
__be32 src_ipv4;
|
|
||||||
u8 dst_addr[ETH_ALEN];
|
|
||||||
u8 src_addr[ETH_ALEN];
|
|
||||||
__be32 port_id;
|
|
||||||
__be16 vlan_tpid;
|
__be16 vlan_tpid;
|
||||||
__be16 vlan_tci;
|
__be16 vlan_tci;
|
||||||
__be32 host_ctx;
|
__be32 host_ctx;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct nfp_tun_neigh_v6 - neighbour/route entry on the NFP
|
* struct nfp_tun_neigh_v4 - neighbour/route entry on the NFP for IPv4
|
||||||
|
* @dst_ipv4: Destination IPv4 address
|
||||||
|
* @src_ipv4: Source IPv4 address
|
||||||
|
* @common: Neighbour/route common info
|
||||||
|
* @ext: Neighbour/route extended info
|
||||||
|
*/
|
||||||
|
struct nfp_tun_neigh_v4 {
|
||||||
|
__be32 dst_ipv4;
|
||||||
|
__be32 src_ipv4;
|
||||||
|
struct nfp_tun_neigh common;
|
||||||
|
struct nfp_tun_neigh_ext ext;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct nfp_tun_neigh_v6 - neighbour/route entry on the NFP for IPv6
|
||||||
* @dst_ipv6: Destination IPv6 address
|
* @dst_ipv6: Destination IPv6 address
|
||||||
* @src_ipv6: Source IPv6 address
|
* @src_ipv6: Source IPv6 address
|
||||||
* @dst_addr: Destination MAC address
|
* @common: Neighbour/route common info
|
||||||
* @src_addr: Source MAC address
|
* @ext: Neighbour/route extended info
|
||||||
* @port_id: NFP port to output packet on - associated with source IPv6
|
|
||||||
* @vlan_tpid: VLAN_TPID match field
|
|
||||||
* @vlan_tci: VLAN_TCI match field
|
|
||||||
* @host_ctx: Host context ID to be saved here
|
|
||||||
*/
|
*/
|
||||||
struct nfp_tun_neigh_v6 {
|
struct nfp_tun_neigh_v6 {
|
||||||
struct in6_addr dst_ipv6;
|
struct in6_addr dst_ipv6;
|
||||||
struct in6_addr src_ipv6;
|
struct in6_addr src_ipv6;
|
||||||
u8 dst_addr[ETH_ALEN];
|
struct nfp_tun_neigh common;
|
||||||
u8 src_addr[ETH_ALEN];
|
struct nfp_tun_neigh_ext ext;
|
||||||
__be32 port_id;
|
|
||||||
__be16 vlan_tpid;
|
|
||||||
__be16 vlan_tci;
|
|
||||||
__be32 host_ctx;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -281,9 +281,15 @@ static int
|
|||||||
nfp_flower_xmit_tun_conf(struct nfp_app *app, u8 mtype, u16 plen, void *pdata,
|
nfp_flower_xmit_tun_conf(struct nfp_app *app, u8 mtype, u16 plen, void *pdata,
|
||||||
gfp_t flag)
|
gfp_t flag)
|
||||||
{
|
{
|
||||||
|
struct nfp_flower_priv *priv = app->priv;
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
unsigned char *msg;
|
unsigned char *msg;
|
||||||
|
|
||||||
|
if (!(priv->flower_ext_feats & NFP_FL_FEATS_DECAP_V2) &&
|
||||||
|
(mtype == NFP_FLOWER_CMSG_TYPE_TUN_NEIGH ||
|
||||||
|
mtype == NFP_FLOWER_CMSG_TYPE_TUN_NEIGH_V6))
|
||||||
|
plen -= sizeof(struct nfp_tun_neigh_ext);
|
||||||
|
|
||||||
skb = nfp_flower_cmsg_alloc(app, plen, mtype, flag);
|
skb = nfp_flower_cmsg_alloc(app, plen, mtype, flag);
|
||||||
if (!skb)
|
if (!skb)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
@ -416,14 +422,14 @@ static void
|
|||||||
nfp_tun_write_neigh_v4(struct net_device *netdev, struct nfp_app *app,
|
nfp_tun_write_neigh_v4(struct net_device *netdev, struct nfp_app *app,
|
||||||
struct flowi4 *flow, struct neighbour *neigh, gfp_t flag)
|
struct flowi4 *flow, struct neighbour *neigh, gfp_t flag)
|
||||||
{
|
{
|
||||||
struct nfp_tun_neigh payload;
|
struct nfp_tun_neigh_v4 payload;
|
||||||
u32 port_id;
|
u32 port_id;
|
||||||
|
|
||||||
port_id = nfp_flower_get_port_id_from_netdev(app, netdev);
|
port_id = nfp_flower_get_port_id_from_netdev(app, netdev);
|
||||||
if (!port_id)
|
if (!port_id)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
memset(&payload, 0, sizeof(struct nfp_tun_neigh));
|
memset(&payload, 0, sizeof(struct nfp_tun_neigh_v4));
|
||||||
payload.dst_ipv4 = flow->daddr;
|
payload.dst_ipv4 = flow->daddr;
|
||||||
|
|
||||||
/* If entry has expired send dst IP with all other fields 0. */
|
/* If entry has expired send dst IP with all other fields 0. */
|
||||||
@ -436,15 +442,15 @@ nfp_tun_write_neigh_v4(struct net_device *netdev, struct nfp_app *app,
|
|||||||
|
|
||||||
/* Have a valid neighbour so populate rest of entry. */
|
/* Have a valid neighbour so populate rest of entry. */
|
||||||
payload.src_ipv4 = flow->saddr;
|
payload.src_ipv4 = flow->saddr;
|
||||||
ether_addr_copy(payload.src_addr, netdev->dev_addr);
|
ether_addr_copy(payload.common.src_addr, netdev->dev_addr);
|
||||||
neigh_ha_snapshot(payload.dst_addr, neigh, netdev);
|
neigh_ha_snapshot(payload.common.dst_addr, neigh, netdev);
|
||||||
payload.port_id = cpu_to_be32(port_id);
|
payload.common.port_id = cpu_to_be32(port_id);
|
||||||
/* Add destination of new route to NFP cache. */
|
/* Add destination of new route to NFP cache. */
|
||||||
nfp_tun_add_route_to_cache_v4(app, &payload.dst_ipv4);
|
nfp_tun_add_route_to_cache_v4(app, &payload.dst_ipv4);
|
||||||
|
|
||||||
send_msg:
|
send_msg:
|
||||||
nfp_flower_xmit_tun_conf(app, NFP_FLOWER_CMSG_TYPE_TUN_NEIGH,
|
nfp_flower_xmit_tun_conf(app, NFP_FLOWER_CMSG_TYPE_TUN_NEIGH,
|
||||||
sizeof(struct nfp_tun_neigh),
|
sizeof(struct nfp_tun_neigh_v4),
|
||||||
(unsigned char *)&payload, flag);
|
(unsigned char *)&payload, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -472,9 +478,9 @@ nfp_tun_write_neigh_v6(struct net_device *netdev, struct nfp_app *app,
|
|||||||
|
|
||||||
/* Have a valid neighbour so populate rest of entry. */
|
/* Have a valid neighbour so populate rest of entry. */
|
||||||
payload.src_ipv6 = flow->saddr;
|
payload.src_ipv6 = flow->saddr;
|
||||||
ether_addr_copy(payload.src_addr, netdev->dev_addr);
|
ether_addr_copy(payload.common.src_addr, netdev->dev_addr);
|
||||||
neigh_ha_snapshot(payload.dst_addr, neigh, netdev);
|
neigh_ha_snapshot(payload.common.dst_addr, neigh, netdev);
|
||||||
payload.port_id = cpu_to_be32(port_id);
|
payload.common.port_id = cpu_to_be32(port_id);
|
||||||
/* Add destination of new route to NFP cache. */
|
/* Add destination of new route to NFP cache. */
|
||||||
nfp_tun_add_route_to_cache_v6(app, &payload.dst_ipv6);
|
nfp_tun_add_route_to_cache_v6(app, &payload.dst_ipv6);
|
||||||
|
|
||||||
@ -1372,7 +1378,7 @@ void nfp_tunnel_config_stop(struct nfp_app *app)
|
|||||||
struct nfp_flower_priv *priv = app->priv;
|
struct nfp_flower_priv *priv = app->priv;
|
||||||
struct nfp_ipv4_addr_entry *ip_entry;
|
struct nfp_ipv4_addr_entry *ip_entry;
|
||||||
struct nfp_tun_neigh_v6 ipv6_route;
|
struct nfp_tun_neigh_v6 ipv6_route;
|
||||||
struct nfp_tun_neigh ipv4_route;
|
struct nfp_tun_neigh_v4 ipv4_route;
|
||||||
struct list_head *ptr, *storage;
|
struct list_head *ptr, *storage;
|
||||||
|
|
||||||
unregister_netevent_notifier(&priv->tun.neigh_nb);
|
unregister_netevent_notifier(&priv->tun.neigh_nb);
|
||||||
@ -1398,7 +1404,7 @@ void nfp_tunnel_config_stop(struct nfp_app *app)
|
|||||||
kfree(route_entry);
|
kfree(route_entry);
|
||||||
|
|
||||||
nfp_flower_xmit_tun_conf(app, NFP_FLOWER_CMSG_TYPE_TUN_NEIGH,
|
nfp_flower_xmit_tun_conf(app, NFP_FLOWER_CMSG_TYPE_TUN_NEIGH,
|
||||||
sizeof(struct nfp_tun_neigh),
|
sizeof(struct nfp_tun_neigh_v4),
|
||||||
(unsigned char *)&ipv4_route,
|
(unsigned char *)&ipv4_route,
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
}
|
}
|
||||||
@ -1412,7 +1418,7 @@ void nfp_tunnel_config_stop(struct nfp_app *app)
|
|||||||
kfree(route_entry);
|
kfree(route_entry);
|
||||||
|
|
||||||
nfp_flower_xmit_tun_conf(app, NFP_FLOWER_CMSG_TYPE_TUN_NEIGH_V6,
|
nfp_flower_xmit_tun_conf(app, NFP_FLOWER_CMSG_TYPE_TUN_NEIGH_V6,
|
||||||
sizeof(struct nfp_tun_neigh),
|
sizeof(struct nfp_tun_neigh_v6),
|
||||||
(unsigned char *)&ipv6_route,
|
(unsigned char *)&ipv6_route,
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user