DPDK usage discussions
 help / color / mirror / Atom feed
* Whether the creatation of flow rules of i40e NIC support tcp port mask
@ 2023-10-17  8:52 jiangheng (G)
  2023-10-17 15:52 ` Stephen Hemminger
  2023-10-18  1:54 ` Xing, Beilei
  0 siblings, 2 replies; 8+ messages in thread
From: jiangheng (G) @ 2023-10-17  8:52 UTC (permalink / raw)
  To: beilei.xing, users; +Cc: Fanbin(Kira,2012 Blue Lab.)

[-- Attachment #1: Type: text/plain, Size: 2856 bytes --]

Hi beilei,

I would like to create flows using tcp port mask, but it seems only mask 0xffff or 0x0 work, Does flow rlue can be created using other mask?

I40e dirver was using now.



Here is my code:

    struct rte_flow_attr attr;

    struct rte_flow_item pattern[MAX_PATTERN_NUM];

    struct rte_flow_action action[MAX_ACTION_NUM];

    struct rte_flow *flow = NULL;

    struct rte_flow_action_queue queue = { .index = queue_id };

    struct rte_flow_item_ipv4 ip_spec;

    struct rte_flow_item_ipv4 ip_mask;

    struct rte_flow_item_tcp tcp_spec;

    struct rte_flow_item_tcp tcp_mask;

    int res;

    memset_s(pattern, sizeof(pattern), 0, sizeof(pattern));

    memset_s(action, sizeof(action), 0, sizeof(action));

    /*

     * set the rule attribute.

     * in this case only ingress packets will be checked.

     */

    memset_s(&attr, sizeof(struct rte_flow_attr), 0, sizeof(struct rte_flow_attr));

    attr.ingress = 1;

    /*

     * create the action sequence.

     * one action only,  move packet to queue

     */

    action[0].type = RTE_FLOW_ACTION_TYPE_QUEUE;

    action[0].conf = &queue;

    action[1].type = RTE_FLOW_ACTION_TYPE_END;

    // not limit eth header

    pattern[0].type = RTE_FLOW_ITEM_TYPE_ETH;

    // ip header

    memset_s(&ip_spec, sizeof(struct rte_flow_item_ipv4), 0, sizeof(struct rte_flow_item_ipv4));

    memset_s(&ip_mask, sizeof(struct rte_flow_item_ipv4), 0, sizeof(struct rte_flow_item_ipv4));

    ip_spec.hdr.dst_addr = dst_ip;

    ip_mask.hdr.dst_addr = EMPTY_MASK;

    ip_spec.hdr.src_addr = src_ip;

    ip_mask.hdr.src_addr = EMPTY_MASK;

    pattern[1].type = RTE_FLOW_ITEM_TYPE_IPV4;

    pattern[1].spec = &ip_spec;

    pattern[1].mask = &ip_mask;

    // tcp header, full mask 0xffff

    memset_s(&tcp_spec, sizeof(struct rte_flow_item_tcp), 0, sizeof(struct rte_flow_item_tcp));

    memset_s(&tcp_mask, sizeof(struct rte_flow_item_tcp), 0, sizeof(struct rte_flow_item_tcp));

    pattern[2].type = RTE_FLOW_ITEM_TYPE_TCP; // 2: pattern 2 is tcp header

    tcp_spec.hdr.src_port = src_port;

    tcp_spec.hdr.dst_port = dst_port;

    tcp_mask.hdr.src_port = 0xffff;  // only 0xffff and 0x0 work

    tcp_mask.hdr.dst_port = 0xffff; // only 0xffff and 0x0 work

    pattern[2].spec = &tcp_spec;

    pattern[2].mask = &tcp_mask;

    /* the final level must be always type end */

    pattern[3].type = RTE_FLOW_ITEM_TYPE_END;

    res = rte_flow_validate(port_id, &attr, pattern, action, error);

    if (!res) {

        flow = rte_flow_create(port_id, &attr, pattern, action, error);

    } else {

        LSTACK_LOG(ERR, PORT, "rte_flow_create.rte_flow_validate error, res %d \n", res);

    }



Looking forward to your favourable reply.


[-- Attachment #2: Type: text/html, Size: 10860 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-10-18 11:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-17  8:52 Whether the creatation of flow rules of i40e NIC support tcp port mask jiangheng (G)
2023-10-17 15:52 ` Stephen Hemminger
2023-10-18  1:48   ` 答复: " jiangheng (G)
2023-10-18  1:54 ` Xing, Beilei
2023-10-18  2:19   ` 答复: " jiangheng (G)
2023-10-18  4:09     ` Xing, Beilei
2023-10-18  7:21       ` Lukáš Šišmiš
2023-10-18 11:16         ` 答复: " jiangheng (G)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).