return 0;
/* we don't support SRC_MAC filtering*/
- if (!rte_is_zero_ether_addr(&mask->src))
+ if (!rte_is_zero_ether_addr(&spec->src) ||
+ (umask && !rte_is_zero_ether_addr(&umask->src)))
return rte_flow_error_set(e, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM,
item,
"src mac filtering not supported");
- if (!rte_is_zero_ether_addr(&mask->dst)) {
- const u8 *addr = (const u8 *)&spec->dst.addr_bytes[0];
- const u8 *m = (const u8 *)&mask->dst.addr_bytes[0];
- struct rte_flow *flow = (struct rte_flow *)fs->private;
- struct port_info *pi = (struct port_info *)
- (flow->dev->data->dev_private);
- int idx;
-
- idx = cxgbe_mpstcam_alloc(pi, addr, m);
- if (idx <= 0)
- return rte_flow_error_set(e, idx,
- RTE_FLOW_ERROR_TYPE_ITEM,
- NULL, "unable to allocate mac"
- " entry in h/w");
- CXGBE_FILL_FS(idx, 0x1ff, macidx);
+ if (!rte_is_zero_ether_addr(&spec->dst) ||
+ (umask && !rte_is_zero_ether_addr(&umask->dst))) {
+ CXGBE_FILL_FS(0, 0x1ff, macidx);
+ CXGBE_FILL_FS_MEMCPY(spec->dst.addr_bytes, mask->dst.addr_bytes,
+ dmac);
}
- CXGBE_FILL_FS(be16_to_cpu(spec->type),
- be16_to_cpu(mask->type), ethtype);
+ if (spec->type || (umask && umask->type))
+ CXGBE_FILL_FS(be16_to_cpu(spec->type),
+ be16_to_cpu(mask->type), ethtype);
return 0;
}
if (val->index > 0x7)
return rte_flow_error_set(e, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
item,
- "port index upto 0x7 is supported");
+ "port index up to 0x7 is supported");
- CXGBE_FILL_FS(val->index, mask->index, iport);
+ if (val->index || (umask && umask->index))
+ CXGBE_FILL_FS(val->index, mask->index, iport);
return 0;
}
/* If user has not given any mask, then use chelsio supported mask. */
mask = umask ? umask : (const struct rte_flow_item_vlan *)dmask;
- if (!fs->mask.ethtype)
- return rte_flow_error_set(e, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
- item,
- "Can't parse VLAN item without knowing ethertype");
-
/* If ethertype is already set and is not VLAN (0x8100) or
* QINQ(0x88A8), then don't proceed further. Otherwise,
* reset the outer ethertype, so that it can be replaced by
if (fs->val.ethtype == RTE_ETHER_TYPE_QINQ) {
CXGBE_FILL_FS(1, 1, ovlan_vld);
if (spec) {
- CXGBE_FILL_FS(be16_to_cpu(spec->tci),
- be16_to_cpu(mask->tci), ovlan);
-
+ if (spec->tci || (umask && umask->tci))
+ CXGBE_FILL_FS(be16_to_cpu(spec->tci),
+ be16_to_cpu(mask->tci), ovlan);
fs->mask.ethtype = 0;
fs->val.ethtype = 0;
}
- } else if (fs->val.ethtype == RTE_ETHER_TYPE_VLAN) {
+ } else {
CXGBE_FILL_FS(1, 1, ivlan_vld);
if (spec) {
- CXGBE_FILL_FS(be16_to_cpu(spec->tci),
- be16_to_cpu(mask->tci), ivlan);
-
+ if (spec->tci || (umask && umask->tci))
+ CXGBE_FILL_FS(be16_to_cpu(spec->tci),
+ be16_to_cpu(mask->tci), ivlan);
fs->mask.ethtype = 0;
fs->val.ethtype = 0;
}
}
- if (spec)
+ if (spec && (spec->inner_type || (umask && umask->inner_type)))
CXGBE_FILL_FS(be16_to_cpu(spec->inner_type),
be16_to_cpu(mask->inner_type), ethtype);
item,
"VF ID > MAX(255)");
- CXGBE_FILL_FS(val->id, mask->id, vf);
+ if (val->id || (umask && umask->id))
+ CXGBE_FILL_FS(val->id, mask->id, vf);
return 0;
}
CXGBE_FILL_FS(IPPROTO_UDP, 0xff, proto);
if (!val)
return 0;
- CXGBE_FILL_FS(be16_to_cpu(val->hdr.src_port),
- be16_to_cpu(mask->hdr.src_port), fport);
- CXGBE_FILL_FS(be16_to_cpu(val->hdr.dst_port),
- be16_to_cpu(mask->hdr.dst_port), lport);
+
+ if (val->hdr.src_port || (umask && umask->hdr.src_port))
+ CXGBE_FILL_FS(be16_to_cpu(val->hdr.src_port),
+ be16_to_cpu(mask->hdr.src_port), fport);
+
+ if (val->hdr.dst_port || (umask && umask->hdr.dst_port))
+ CXGBE_FILL_FS(be16_to_cpu(val->hdr.dst_port),
+ be16_to_cpu(mask->hdr.dst_port), lport);
+
return 0;
}
CXGBE_FILL_FS(IPPROTO_TCP, 0xff, proto);
if (!val)
return 0;
- CXGBE_FILL_FS(be16_to_cpu(val->hdr.src_port),
- be16_to_cpu(mask->hdr.src_port), fport);
- CXGBE_FILL_FS(be16_to_cpu(val->hdr.dst_port),
- be16_to_cpu(mask->hdr.dst_port), lport);
+
+ if (val->hdr.src_port || (umask && umask->hdr.src_port))
+ CXGBE_FILL_FS(be16_to_cpu(val->hdr.src_port),
+ be16_to_cpu(mask->hdr.src_port), fport);
+
+ if (val->hdr.dst_port || (umask && umask->hdr.dst_port))
+ CXGBE_FILL_FS(be16_to_cpu(val->hdr.dst_port),
+ be16_to_cpu(mask->hdr.dst_port), lport);
+
return 0;
}
if (!val)
return 0; /* ipv4 wild card */
- CXGBE_FILL_FS(val->hdr.next_proto_id, mask->hdr.next_proto_id, proto);
- CXGBE_FILL_FS_MEMCPY(val->hdr.dst_addr, mask->hdr.dst_addr, lip);
- CXGBE_FILL_FS_MEMCPY(val->hdr.src_addr, mask->hdr.src_addr, fip);
- CXGBE_FILL_FS(val->hdr.type_of_service, mask->hdr.type_of_service, tos);
+ if (val->hdr.next_proto_id || (umask && umask->hdr.next_proto_id))
+ CXGBE_FILL_FS(val->hdr.next_proto_id, mask->hdr.next_proto_id,
+ proto);
+
+ if (val->hdr.dst_addr || (umask && umask->hdr.dst_addr))
+ CXGBE_FILL_FS_MEMCPY(val->hdr.dst_addr, mask->hdr.dst_addr,
+ lip);
+
+ if (val->hdr.src_addr || (umask && umask->hdr.src_addr))
+ CXGBE_FILL_FS_MEMCPY(val->hdr.src_addr, mask->hdr.src_addr,
+ fip);
+
+ if (val->hdr.type_of_service || (umask && umask->hdr.type_of_service))
+ CXGBE_FILL_FS(val->hdr.type_of_service,
+ mask->hdr.type_of_service, tos);
return 0;
}
const struct rte_flow_item_ipv6 *umask = item->mask;
const struct rte_flow_item_ipv6 *mask;
u32 vtc_flow, vtc_flow_mask;
+ u8 z[16] = { 0 };
mask = umask ? umask : (const struct rte_flow_item_ipv6 *)dmask;
if (!val)
return 0; /* ipv6 wild card */
- CXGBE_FILL_FS(val->hdr.proto, mask->hdr.proto, proto);
+ if (val->hdr.proto || (umask && umask->hdr.proto))
+ CXGBE_FILL_FS(val->hdr.proto, mask->hdr.proto, proto);
vtc_flow = be32_to_cpu(val->hdr.vtc_flow);
- CXGBE_FILL_FS((vtc_flow & RTE_IPV6_HDR_TC_MASK) >>
- RTE_IPV6_HDR_TC_SHIFT,
- (vtc_flow_mask & RTE_IPV6_HDR_TC_MASK) >>
- RTE_IPV6_HDR_TC_SHIFT,
- tos);
-
- CXGBE_FILL_FS_MEMCPY(val->hdr.dst_addr, mask->hdr.dst_addr, lip);
- CXGBE_FILL_FS_MEMCPY(val->hdr.src_addr, mask->hdr.src_addr, fip);
+ if (val->hdr.vtc_flow || (umask && umask->hdr.vtc_flow))
+ CXGBE_FILL_FS((vtc_flow & RTE_IPV6_HDR_TC_MASK) >>
+ RTE_IPV6_HDR_TC_SHIFT,
+ (vtc_flow_mask & RTE_IPV6_HDR_TC_MASK) >>
+ RTE_IPV6_HDR_TC_SHIFT,
+ tos);
+
+ if (memcmp(val->hdr.dst_addr, z, sizeof(val->hdr.dst_addr)) ||
+ (umask &&
+ memcmp(umask->hdr.dst_addr, z, sizeof(umask->hdr.dst_addr))))
+ CXGBE_FILL_FS_MEMCPY(val->hdr.dst_addr, mask->hdr.dst_addr,
+ lip);
+
+ if (memcmp(val->hdr.src_addr, z, sizeof(val->hdr.src_addr)) ||
+ (umask &&
+ memcmp(umask->hdr.src_addr, z, sizeof(umask->hdr.src_addr))))
+ CXGBE_FILL_FS_MEMCPY(val->hdr.src_addr, mask->hdr.src_addr,
+ fip);
return 0;
}
}
}
- cxgbe_fill_filter_region(adap, &flow->fs);
cxgbe_tweak_filter_spec(adap, &flow->fs);
+ cxgbe_fill_filter_region(adap, &flow->fs);
return 0;
}
return ctx.result;
}
- fs = &flow->fs;
- if (fs->mask.macidx) {
- struct port_info *pi = (struct port_info *)
- (dev->data->dev_private);
- int ret;
-
- ret = cxgbe_mpstcam_remove(pi, fs->val.macidx);
- if (!ret)
- return ret;
- }
-
return 0;
}
flow->item_parser = parseitem;
flow->dev = dev;
+ flow->fs.private = (void *)flow;
ret = cxgbe_flow_parse(flow, attr, item, action, e);
if (ret) {
}
/*
- * @ret : > 0 filter destroyed succsesfully
+ * @ret : > 0 filter destroyed successfully
* < 0 error destroying filter
* == 1 filter not active / not found
*/
};
int
-cxgbe_dev_filter_ctrl(struct rte_eth_dev *dev,
- enum rte_filter_type filter_type,
- enum rte_filter_op filter_op,
- void *arg)
+cxgbe_dev_flow_ops_get(struct rte_eth_dev *dev __rte_unused,
+ const struct rte_flow_ops **ops)
{
- int ret = 0;
-
- RTE_SET_USED(dev);
- switch (filter_type) {
- case RTE_ETH_FILTER_GENERIC:
- if (filter_op != RTE_ETH_FILTER_GET)
- return -EINVAL;
- *(const void **)arg = &cxgbe_flow_ops;
- break;
- default:
- ret = -ENOTSUP;
- break;
- }
- return ret;
+ *ops = &cxgbe_flow_ops;
+ return 0;
}