bogdanPricope replied on github web page:

platform/linux-generic/include/odp_pktio_ops_subsystem.h
line 33
@@ -85,12 +86,39 @@ typedef ODP_MODULE_CLASS(pktio_ops) {
        odp_api_proto(pktio_ops, print) print;
 } pktio_ops_module_t;
 
-/* Maximum size of pktio specific ops data.*/
-#define ODP_PKTIO_ODPS_DATA_MAX_SIZE 80000
+/* Pktio ops data pool */
+#define ODP_PKTIO_OPS_DATA_POOL_SIZE 160000
+#define ODP_PKTIO_OPS_DATA_POOL_NAME "ODP_PKTIO_OPS_DATA"
 
 /* Extract pktio ops data from pktio entry structure */
 #define odp_ops_data(_p, _mod) \
-       ((pktio_ops_ ## _mod ## _data_t *)(uintptr_t)_p->s.ops_data)
+       ((pktio_ops_ ## _mod ## _data_t *)_p->s.ops_data)
+
+#define odp_ops_data_alloc(_p, _mod)                                   \
+({ \
+       odpdrv_shm_pool_t _pool = ODPDRV_SHM_POOL_INVALID;              \
+       uint64_t _size = sizeof(pktio_ops_ ## _mod ## _data_t);         \
+                                                                       \
+       _p->s.ops_data = NULL;                  \
+       _pool = odpdrv_shm_pool_lookup(ODP_PKTIO_OPS_DATA_POOL_NAME);   \
+       if (_pool != ODPDRV_SHM_POOL_INVALID)                           \
+               _p->s.ops_data = odpdrv_shm_pool_alloc(_pool, _size);   \
+                                                                       \
+       ((pktio_ops_ ## _mod ## _data_t *)_p->s.ops_data);              \


Comment:
It will require a cast when is called. 
A pktio_type may implement another way to allocate memory starting form the 
name of the pool / is not mandatory to use those macros but are helpful for 
existing pktio types.

> bogdanPricope wrote
> _p comes form (pktio_entry_t *)


>> Josep Puigdemont(joseppc) wrote:
>> It probably belongs to its own patch, but now that you are at it, it could 
>> even be moved even further up, as it is probably faster than checking for 
>> "tap:" in the device string.


>>> Josep Puigdemont(joseppc) wrote:
>>> (_p)?  There are a couple more, also in odp_ops_data_free.


>>>> Josep Puigdemont(joseppc) wrote:
>>>> Maybe we can return (void *)? This way we would not care if pktios name 
>>>> (or define) their private structures according to the naming conventions 
>>>> implicit in the macro.


https://github.com/Linaro/odp/pull/297#discussion_r151403175
updated_at 2017-11-16 12:45:21

Reply via email to