2 #include <linux/if_ether.h>
3 #include <linux/if_link.h>
4 #include <linux/netdevice.h>
6 #include <linux/types.h>
7 #include <linux/skbuff.h>
8 #include <net/flow_keys.h>
10 #include "enic_clsf.h"
12 /* enic_addfltr_5t - Add ipv4 5tuple filter
13 * @enic: enic struct of vnic
14 * @keys: flow_keys of ipv4 5tuple
15 * @rq: rq number to steer to
17 * This function returns filter_id(hardware_id) of the filter
18 * added. In case of error it returns an negative number.
20 int enic_addfltr_5t(struct enic *enic, struct flow_keys *keys, u16 rq)
25 switch (keys->ip_proto) {
27 data.u.ipv4.protocol = PROTO_TCP;
30 data.u.ipv4.protocol = PROTO_UDP;
33 return -EPROTONOSUPPORT;
35 data.type = FILTER_IPV4_5TUPLE;
36 data.u.ipv4.src_addr = ntohl(keys->src);
37 data.u.ipv4.dst_addr = ntohl(keys->dst);
38 data.u.ipv4.src_port = ntohs(keys->port16[0]);
39 data.u.ipv4.dst_port = ntohs(keys->port16[1]);
40 data.u.ipv4.flags = FILTER_FIELDS_IPV4_5TUPLE;
42 spin_lock_bh(&enic->devcmd_lock);
43 res = vnic_dev_classifier(enic->vdev, CLSF_ADD, &rq, &data);
44 spin_unlock_bh(&enic->devcmd_lock);
45 res = (res == 0) ? rq : res;
50 /* enic_delfltr - Delete clsf filter
51 * @enic: enic struct of vnic
52 * @filter_id: filter_is(hardware_id) of filter to be deleted
54 * This function returns zero in case of success, negative number incase of
57 int enic_delfltr(struct enic *enic, u16 filter_id)
61 spin_lock_bh(&enic->devcmd_lock);
62 ret = vnic_dev_classifier(enic->vdev, CLSF_DEL, &filter_id, NULL);
63 spin_unlock_bh(&enic->devcmd_lock);