From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4DDC94318A for ; Tue, 17 Oct 2023 10:52:27 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4001D40279; Tue, 17 Oct 2023 10:52:27 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 411D940269 for ; Tue, 17 Oct 2023 10:52:25 +0200 (CEST) Received: from canpemm500007.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4S8nhD14qszVlXc for ; Tue, 17 Oct 2023 16:48:44 +0800 (CST) Received: from canpemm500004.china.huawei.com (7.192.104.92) by canpemm500007.china.huawei.com (7.192.104.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Tue, 17 Oct 2023 16:52:22 +0800 Received: from dggpeml500020.china.huawei.com (7.185.36.88) by canpemm500004.china.huawei.com (7.192.104.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Tue, 17 Oct 2023 16:52:22 +0800 Received: from dggpeml500020.china.huawei.com ([7.185.36.88]) by dggpeml500020.china.huawei.com ([7.185.36.88]) with mapi id 15.01.2507.031; Tue, 17 Oct 2023 16:52:22 +0800 From: "jiangheng (G)" To: "beilei.xing@intel.com" , "users@dpdk.org" CC: "Fanbin(Kira,2012 Blue Lab.)" Subject: Whether the creatation of flow rules of i40e NIC support tcp port mask Thread-Topic: Whether the creatation of flow rules of i40e NIC support tcp port mask Thread-Index: AdoA1zKopRhb/mz0T4qZQSq4v/eEUg== Date: Tue, 17 Oct 2023 08:52:22 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.136.117.195] Content-Type: multipart/alternative; boundary="_000_ca071f7ccde7402ea223f7295e1cca4fhuaweicom_" MIME-Version: 1.0 X-CFilter-Loop: Reflected X-BeenThere: users@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK usage discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: users-bounces@dpdk.org --_000_ca071f7ccde7402ea223f7295e1cca4fhuaweicom_ Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: base64 SGkgYmVpbGVpo6wNCg0KSSB3b3VsZCBsaWtlIHRvIGNyZWF0ZSBmbG93cyB1c2luZyB0Y3AgcG9y dCBtYXNrLCBidXQgaXQgc2VlbXMgb25seSBtYXNrIDB4ZmZmZiBvciAweDAgd29yaywgRG9lcyBm bG93IHJsdWUgY2FuIGJlIGNyZWF0ZWQgdXNpbmcgb3RoZXIgbWFzaz8NCg0KSTQwZSBkaXJ2ZXIg d2FzIHVzaW5nIG5vdy4NCg0KDQoNCkhlcmUgaXMgbXkgY29kZToNCg0KICAgIHN0cnVjdCBydGVf Zmxvd19hdHRyIGF0dHI7DQoNCiAgICBzdHJ1Y3QgcnRlX2Zsb3dfaXRlbSBwYXR0ZXJuW01BWF9Q QVRURVJOX05VTV07DQoNCiAgICBzdHJ1Y3QgcnRlX2Zsb3dfYWN0aW9uIGFjdGlvbltNQVhfQUNU SU9OX05VTV07DQoNCiAgICBzdHJ1Y3QgcnRlX2Zsb3cgKmZsb3cgPSBOVUxMOw0KDQogICAgc3Ry dWN0IHJ0ZV9mbG93X2FjdGlvbl9xdWV1ZSBxdWV1ZSA9IHsgLmluZGV4ID0gcXVldWVfaWQgfTsN Cg0KICAgIHN0cnVjdCBydGVfZmxvd19pdGVtX2lwdjQgaXBfc3BlYzsNCg0KICAgIHN0cnVjdCBy dGVfZmxvd19pdGVtX2lwdjQgaXBfbWFzazsNCg0KICAgIHN0c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X3NwZWMuaGRyLnNyY19wb3J0ID0gc3JjX3Bv cnQ7DQoNCiAgICB0Y3Bfc3BlYy5oZHIuZHN0X3BvcnQgPSBkc3RfcG9ydDsNCg0KICAgIHRjcF9t YXNrLmhkci5zcmNfcG9ydCA9IDB4ZmZmZjsgIC8vIG9ubHkgMHhmZmZmIGFuZCAweDAgd29yaw0K DQogICAgdGNwX21hc2suaGRyLmRzdF9wb3J0ID0gMHhmZmZmOyAvLyBvbmx5IDB4ZmZmZiBhbmQg MHgwIHdvcmsNCg0KICAgIHBhdHRlcm5bMl0uc3BlYyA9ICZ0Y3Bfc3BlYzsNCg0KICAgIHBhdHRl cm5bMl0ubWFzayA9ICZ0Y3BfbWFzazsNCg0KICAgIC8qIHRoZSBmaW5hbCBsZXZlbCBtdXN0IGJl IGFsd2F5cyB0eXBlIGVuZCAqLw0KDQogICAgcGF0dGVyblszXS50eXBlID0gUlRFX0ZMT1dfSVRF TV9UWVBFX0VORDsNCg0KICAgIHJlcyA9IHJ0ZV9mbG93X3ZhbGlkYXRlKHBvcnRfaWQsICZhdHRy LCBwYXR0ZXJuLCBhY3Rpb24sIGVycm9yKTsNCg0KICAgIGlmICghcmVzKSB7DQoNCiAgICAgICAg ZmxvdyA9IHJ0ZV9mbG93X2NyZWF0ZShwb3J0X2lkLCAmYXR0ciwgcGF0dGVybiwgYWN0aW9uLCBl cnJvcik7DQoNCiAgICB9IGVsc2Ugew0KDQogICAgICAgIExTVEFDS19MT0coRVJSLCBQT1JULCAi cnRlX2Zsb3dfY3JlYXRlLnJ0ZV9mbG93X3ZhbGlkYXRlIGVycm9yLCByZXMgJWQgXG4iLCByZXMp Ow0KDQogICAgfQ0KDQoNCg0KTG9va2luZyBmb3J3YXJkIHRvIHlvdXIgZmF2b3VyYWJsZSByZXBs eS4NCg0K --_000_ca071f7ccde7402ea223f7295e1cca4fhuaweicom_ Content-Type: text/html; charset="gb2312" Content-Transfer-Encoding: quoted-printable

Hi beilei=A3=AC=

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 ot= her mask?

I40e dirver was using now. <= o:p>

   

Here is my code:<= /span>

    struct rt= e_flow_attr attr;

    struct rt= e_flow_item pattern[MAX_PATTERN_NUM];

    struct rt= e_flow_action action[MAX_ACTION_NUM];

    struct rt= e_flow *flow =3D NULL;

    struct rt= e_flow_action_queue queue =3D { .index =3D queue_id };

    struct rt= e_flow_item_ipv4 ip_spec;

    struct rt= e_flow_item_ipv4 ip_mask;

    stru= ct rte_flow_item_tcp tcp_spec;

    struct rt= e_flow_item_tcp tcp_mask;

    int res;<= o:p>

    mems= et_s(pattern, sizeof(pattern), 0, sizeof(pattern));

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

    /*

     * s= et the rule attribute.

     * i= n this case only ingress packets will be checked.

     */<= o:p>

    memset_s(= &attr, sizeof(struct rte_flow_attr), 0, sizeof(struct rte_flow_attr));<= o:p>

    attr.ingr= ess =3D 1;

    /*

     * c= reate the action sequence.

     * o= ne action only,  move packet to queue

     */<= o:p>

    action[0]= .type =3D RTE_FLOW_ACTION_TYPE_QUEUE;

    action[0]= .conf =3D &queue;

    action[1]= .type =3D RTE_FLOW_ACTION_TYPE_END;

    // n= ot limit eth header

    pattern[0= ].type =3D RTE_FLOW_ITEM_TYPE_ETH;

    // i= p 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.h= dr.dst_addr =3D dst_ip;

    ip_mask.h= dr.dst_addr =3D EMPTY_MASK;

    ip_spec.h= dr.src_addr =3D src_ip;

    ip_mask.h= dr.src_addr =3D EMPTY_MASK;

    pattern[1= ].type =3D RTE_FLOW_ITEM_TYPE_IPV4;

    pattern[1= ].spec =3D &ip_spec;

    pattern[1= ].mask =3D &ip_mask;

    // t= cp 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 =3D RTE_FLOW_ITEM_TYPE_TCP; // 2: pattern 2 is tcp header=

    tcp_spec.= hdr.src_port =3D src_port;

    tcp_spec.= hdr.dst_port =3D dst_port;

 = ;   tcp_mask.hdr.src_port =3D 0xffff;  // only 0xffff and 0x= 0 work

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

    pattern[2= ].spec =3D &tcp_spec;

    pattern[2= ].mask =3D &tcp_mask;

    /* t= he final level must be always type end */

    pattern[3= ].type =3D RTE_FLOW_ITEM_TYPE_END;

    res =3D r= te_flow_validate(port_id, &attr, pattern, action, error);

    if (!res)= {

    &nbs= p;   flow =3D rte_flow_create(port_id, &attr, pattern, action= , error);

    } else {<= o:p>

    &nbs= p;   LSTACK_LOG(ERR, PORT, "rte_flow_create.rte_flow_validat= e error, res %d \n", res);

    }

 

Looking forward to your favo= urable reply.

 

--_000_ca071f7ccde7402ea223f7295e1cca4fhuaweicom_--