From 3f92bed3d6c073f41efc0777ecd3442aa1f03d20 Mon Sep 17 00:00:00 2001 From: Upinder Malhi Date: Thu, 9 Jan 2014 14:48:15 -0800 Subject: IB/usnic: Add UDP support to usnic_fwd.[hc] Add *ip field* to *struct usnic_fwd_dev* as well as new *functions* to manipulate the *ip field.* Furthermore, add new functions for programming UDP flows in the forwarding device. Signed-off-by: Upinder Malhi Signed-off-by: Roland Dreier --- drivers/infiniband/hw/usnic/usnic_fwd.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'drivers/infiniband/hw/usnic/usnic_fwd.h') diff --git a/drivers/infiniband/hw/usnic/usnic_fwd.h b/drivers/infiniband/hw/usnic/usnic_fwd.h index b146eb97d82c..93713a2230b3 100644 --- a/drivers/infiniband/hw/usnic/usnic_fwd.h +++ b/drivers/infiniband/hw/usnic/usnic_fwd.h @@ -40,6 +40,7 @@ struct usnic_fwd_dev { bool link_up; char mac[ETH_ALEN]; unsigned int mtu; + __be32 inaddr; char name[IFNAMSIZ+1]; }; @@ -58,6 +59,8 @@ struct usnic_fwd_dev *usnic_fwd_dev_alloc(struct pci_dev *pdev); void usnic_fwd_dev_free(struct usnic_fwd_dev *ufdev); void usnic_fwd_set_mac(struct usnic_fwd_dev *ufdev, char mac[ETH_ALEN]); +int usnic_fwd_add_ipaddr(struct usnic_fwd_dev *ufdev, __be32 inaddr); +void usnic_fwd_del_ipaddr(struct usnic_fwd_dev *ufdev); void usnic_fwd_carrier_up(struct usnic_fwd_dev *ufdev); void usnic_fwd_carrier_down(struct usnic_fwd_dev *ufdev); void usnic_fwd_set_mtu(struct usnic_fwd_dev *ufdev, unsigned int mtu); @@ -89,4 +92,22 @@ static inline void usnic_fwd_init_usnic_filter(struct filter *filter, filter->u.usnic.usnic_id = usnic_id; } +static inline void usnic_fwd_init_udp_filter(struct filter *filter, + uint32_t daddr, uint16_t dport) +{ + filter->type = FILTER_IPV4_5TUPLE; + filter->u.ipv4.flags = FILTER_FIELD_5TUP_PROTO; + filter->u.ipv4.protocol = PROTO_UDP; + + if (daddr) { + filter->u.ipv4.flags |= FILTER_FIELD_5TUP_DST_AD; + filter->u.ipv4.dst_addr = daddr; + } + + if (dport) { + filter->u.ipv4.flags |= FILTER_FIELD_5TUP_DST_PT; + filter->u.ipv4.dst_port = dport; + } +} + #endif /* !USNIC_FWD_H_ */ -- cgit v1.2.3