From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [119.145.14.66]) by dpdk.org (Postfix) with ESMTP id D80BE2716 for ; Thu, 14 May 2015 02:27:06 +0200 (CEST) Received: from 172.24.2.119 (EHLO SZXEMA412-HUB.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BFZ70580; Thu, 14 May 2015 08:27:04 +0800 (CST) Received: from SZXEMA511-MBX.china.huawei.com ([169.254.5.65]) by SZXEMA412-HUB.china.huawei.com ([10.82.72.71]) with mapi id 14.03.0158.001; Thu, 14 May 2015 08:26:56 +0800 From: Guojiachun To: "dev@dpdk.org" Thread-Topic: proposal: raw packet send and receive API for PMD driver Thread-Index: AdCN3KyhmeNGzw20St+tLwebwBYuqQ== Date: Thu, 14 May 2015 00:26:55 +0000 Message-ID: <1E73E9B18F45624F846581D842CE31CF22752789@SZXEMA511-MBX.china.huawei.com> Accept-Language: en-US, zh-CN Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.111.71.226] MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.5553EBD8.0182, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=169.254.5.65, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 444ea764fe737669d4afe3443aa58e9d Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Cc: "Jiangtao \(IP Arch\)" , "Liujun \(Johnson\)" Subject: [dpdk-dev] proposal: raw packet send and receive API for PMD driver X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 May 2015 00:27:08 -0000 Hello, This is our proposal to introduce new PMD APIs, it would be much better to = integrate DPDK into various applications. There is a gap in hardware offload when you porting DPDK to new platform wh= ich support some offload features, like packet accelerator, buffer manageme= nt etc. If we can make some supplement to it. It will be easy for porting DPDK to n= ew NIC/platform. 1. Packet buffer management The PMD driver use DPDK software mempool API to get/put packet buffer in cu= rrently. But in other cases, the hardware maybe support buffer management u= nit. We can use hardware buffer-unit replaces DPDK software mempool to gain= efficiencies. So we need to register get/put hook APIs to these eth_dev. D= efined as following: /* include and */ typedef int (*rbuf_bulk_get_hook)(void* mempool, void **obj_table, unsigned= n); typedef int (*rbuf_bulk_free_hook)(void* memaddr); typedef int (*eth_dev_init_t)(struct eth_driver *eth_drv, struct rte_eth_= dev *eth_dev, rbuf_bulk_get_hook *rbuf_get, rbuf_bulk_fr= ee_hook *rbuf_free); If there are no hardware buffer-unit, we can register the currentl= y rte_mempool APIs in eth_dev_init(). Each driver use these API hook but no= t rte_mempool_get_bulk()/rte_mempool_put(). 2. Recv/send API and raw_buf The hardware offload feature differences exist between the NICs. Currently = defined in rte_mbuf for rx/tx offload can't applying all NIC. And sometimes= modifying rte_mbuf also need to modify all PMD driver. But we can define a= union rte_rbuf to resolve it. struct rte_rbuf { void *buf_addr; /**< Virtual address of segment buffer. = */ phys_addr_t buf_physaddr; /**< Physical address of segment buffer.= */ uint16_t buf_len; /**< Length of segment buffer. */ uint16_t data_off; uint8_t nb_segs; /**< Number of segments. */ union{ struct{ uint32_t rx_offload_data[8]; uint32_t tx_offload_data[8]; } offload_data; struct{ /* intel nic offload define*/ uint32_t rss; uint64_t tx_offload; ... }intel_offload; /* other NIC offload define */ ... } /* offload define */ } 3. RTE_PKTMBUF_HEADROOM Each PMD driver need to fill rte_mbuf->data_off according to the macro: RTE= _PKTMBUF_HEADROOM. But in some cases, different application need different = RTE_PKTMBUF_HEADROOM. Once changing the value of RTE_PKTMBUF_HEADROOM, it s= hould to re-compile all drivers. That means different application need diff= erent driver lib, but not the same one. So we can pass a argument dynamically in eth_dev_init() to replace the MACR= O: RTE_PKTMBUF_HEADROOM. Therefore, we can add these APIs as following: struct rte_rbuf { void *buf_addr; /**< Virtual address of segment buffer. = */ phys_addr_t buf_physaddr; /**< Physical address of segment buffer.= */ uint16_t buf_len; /**< Length of segment buffer. */ uint16_t data_off; uint8_t nb_segs; /**< Number of segments. */ union{ struct{ uint32_t rx_offload_data[8]; uint32_t tx_offload_data[8]; } offload_data; struct{ /* intel nic offload define*/ uint32_t rss; uint64_t tx_offload; ... }intel_offload; /* other NIC offload define */ ... } /* offload define */ } uint16_t rte_eth_tx_raw_burst(uint8_t port_id, uint16_t queue_id, struct rt= e_rbuf **tx_pkts, uint16_t nb_pkts); uint16_t rte_eth_rx_raw_burst(uint8_t port_id, uint16_t queue_id, struct rt= e_rbuf **rx_pkts, uint16_t nb_pkts); /* include and */ typedef int (*rbuf_bulk_get_hook)(void* mempool, void **obj_table, unsigned= n); typedef int (*rbuf_bulk_free_hook)(void* memaddr); /* use 'headroom_offset' to replace compile MARCO(CONFIG_RTE_PKTMBUF_HEADRO= OM) */ typedef int (*eth_dev_init_t)(struct eth_driver *eth_drv, struct rte_eth_= dev *eth_dev, rbuf_bulk_get_hook *rbuf_get, rbuf_bulk_fr= ee_hook *rbuf_free, uint16_t headroom_offset); These are my ideas, I hope you can help me to improve on them. Thank you! Jiachun