On Fri, Nov 13, 2015 at 1:49 AM, Savolainen, Petri (Nokia - FI/Espoo) < [email protected]> wrote:
> > > > > *From:* EXT Bill Fischofer [mailto:[email protected]] > *Sent:* Thursday, November 12, 2015 9:48 PM > *To:* Savolainen, Petri (Nokia - FI/Espoo) > *Cc:* LNG ODP Mailman List > *Subject:* Re: [lng-odp] [API-NEXT PATCH v2 2/5] api: pktio: added > multiple pktio input queues > > > > > > > > On Thu, Nov 12, 2015 at 6:46 AM, Petri Savolainen < > [email protected]> wrote: > > Added input queue configuration parameters and functions > to setup multiple input queue and hashing. Added also > functions to query the number of queues and queue handles. > Direct receive does use new odp_pktin_queue_t handle type. > > Signed-off-by: Petri Savolainen <[email protected]> > --- > include/odp/api/packet_io.h | 133 > +++++++++++++++++++++ > .../include/odp/plat/packet_io_types.h | 2 + > 2 files changed, 135 insertions(+) > > diff --git a/include/odp/api/packet_io.h b/include/odp/api/packet_io.h > index 264fa75..a27d88a 100644 > --- a/include/odp/api/packet_io.h > +++ b/include/odp/api/packet_io.h > @@ -19,6 +19,7 @@ extern "C" { > #endif > > #include <odp/api/packet_io_stats.h> > +#include <odp/api/queue.h> > > /** @defgroup odp_packet_io ODP PACKET IO > * Operations on a packet Input/Output interface. > @@ -42,6 +43,11 @@ extern "C" { > */ > > /** > + * @typedef odp_pktin_queue_t > + * Direct packet input queue handle > + */ > + > +/** > * @def ODP_PKTIO_INVALID > * Invalid packet IO handle > */ > @@ -85,6 +91,63 @@ typedef enum odp_pktio_output_mode_t { > } odp_pktio_output_mode_t; > > /** > + * Packet input hash protocols > + * > + * The list of protocol header field combinations, which are included into > + * packet input hash calculation. > + */ > +typedef union odp_pktin_hash_proto_t { > + /** Protocol header fields for hashing */ > + struct { > + /** IPv4 addresses and UDP port numbers */ > + uint32_t ipv4_udp : 1; > + /** IPv4 addresses and TCP port numbers */ > + uint32_t ipv4_tcp : 1; > + /** IPv4 addresses */ > + uint32_t ipv4 : 1; > + /** IPv6 addresses and UDP port numbers */ > + uint32_t ipv6_udp : 1; > + /** IPv6 addresses and TCP port numbers */ > + uint32_t ipv6_tcp : 1; > + /** IPv6 addresses */ > + uint32_t ipv6 : 1; > + } proto; > > > > This seems to invite a combinatorial explosion of bits as more protocols > are added. Why not separate by layers and simply have selector bits for the > protocols of interest at that layer, i.e, L3 has IPv4 and IPv6, L4 has TCP > and UDP, etc.? That's what the classifier does so even if we want to have > this as an alternative to the classifier it would make sense to try to be > consistent with it. > > > > The idea is that if e.g. > > - ipv4_udp and ipv4 are set ==> hash IPv4/UDP and other IPv4 > packets > > - only ipv4_udp is set ==> hash only IPv4/UDP packets, ignore > other IPv4 packets > > > > The set of combinations defined here can be more limited than what a full > featured classification engine can do. These combinations should match > typical hashing use cases and NIC capabilities. > > > Which NICs are we considering? Typical NICs support RSS, which provides for much more flexibility than is offered here. For them DPDK defines the following struct: /** * A structure used to configure the Receive Side Scaling (RSS) feature * of an Ethernet port. * If not NULL, the *rss_key* pointer of the *rss_conf* structure points * to an array holding the RSS key to use for hashing specific header * fields of received packets. The length of this array should be indicated * by *rss_key_len* below. Otherwise, a default random hash key is used by * the device driver. * * The *rss_key_len* field of the *rss_conf* structure indicates the length * in bytes of the array pointed by *rss_key*. To be compatible, this length * will be checked in i40e only. Others assume 40 bytes to be used as before. * * The *rss_hf* field of the *rss_conf* structure indicates the different * types of IPv4/IPv6 packets to which the RSS hashing must be applied. * Supplying an *rss_hf* equal to zero disables the RSS feature. */ struct rte_eth_rss_conf { uint8_t *rss_key; /**< If not NULL, 40-byte hash key. */ uint8_t rss_key_len; /**< hash key length in bytes. */ uint64_t rss_hf; /**< Hash functions to apply - see below. */ }; If we're trying to match DPDK capability with regards to rings == pktio input queues then why not just adopt this structure? > > + > + /** All bits of the bit field structure */ > + uint32_t all_bits; > +} odp_pktin_hash_proto_t; > + > +/** > + * Packet input queue parameters > + */ > +typedef struct odp_pktio_input_queue_param_t { > + /** Enable performance optimization for single thread per queue > + * 0: Queue is multi-thread safe, 1: Queue is for single thread */ > + odp_bool_t single_thr; > > > > Overly cryptic. single_thread would be clearer. > > > > + > + /** Enable flow hashing > + * 0: Do not hash, 1: Hash flows to input queues */ > + odp_bool_t hash_ena; > > > > Overly cryptic. hash_enable would be clearer. > > > > Sure, I can expand these. Although, we have a “thrmask” API already. > > > > + > + /** Protocol field selection for hashing. Multiple protocols can be > + * selected. */ > + odp_pktin_hash_proto_t hash_proto; > + > + /** Number of input queues to be created. More than one input queue > + * require input hashing or classifier setup. Hash_proto is > ignored > + * when hash_ena is zero or num_queues is one. This value must be > + * between 1 and interface capability. Queue type is defined by > the > + * input mode. */ > + unsigned num_queues; > + > + /** Queue parameters for creating input queues in > ODP_PKTIN_MODE_POLL > + * or ODP_PKTIN_MODE_SCHED modes. Scheduler parameters are > considered > + * only in ODP_PKTIN_MODE_SCHED mode. */ > + odp_queue_param_t queue_param; > + > +} odp_pktio_input_queue_param_t; > + > +/** > * Packet IO parameters > * > * In minimum, user must select input and output modes. Use 0 for > defaults. > @@ -158,6 +221,67 @@ odp_pktio_t odp_pktio_open(const char *dev, > odp_pool_t pool, > int odp_pktio_capability(odp_pktio_t pktio, odp_pktio_capability_t *capa); > > /** > + * Configure packet input queues > + * > + * Setup a number of packet input queues and configure those. The maximum > number > + * of queues is platform dependent and can be queried with > + * odp_pktio_capability(). Queue handles for input queues can be > requested with > + * odp_pktio_in_queues() or odp_pktio_pktin_queues() after this call. All > + * requested queues are setup on success, no queues are setup on failure. > + * > + * @param pktio Packet IO handle > + * @param param Packet input queue configuration parameters > + * > + * @retval 0 on success > + * @retval <0 on failure > + * > + * @see odp_pktio_capability(), odp_pktio_in_queues(), > odp_pktio_pktin_queues() > + */ > +int odp_pktio_input_queues_config(odp_pktio_t pktio, > + const odp_pktio_input_queue_param_t > *param); > + > +/** > + * Queues for packet input > + * > + * Returns the number of input queues configured for the interface in > + * ODP_PKTIN_MODE_POLL and ODP_PKTIN_MODE_SCHED modes. Outputs up to > 'num' queue > + * handles when the 'queues' array pointer is not NULL. If return value is > + * larger than 'num', there are more queues than the function was allowed > to > + * output. > + * > + * Packets (and other events) from these queues are received with > + * odp_queue_deq(), odp_schedule(), etc calls. > + * > + * @param pktio Packet IO handle > + * @param[out] queues Points to an array of queue handles for output > + * @param num Maximum number of queue handles to output > + * > + * @return Number of packet input queues > + * @retval <0 on failure > + */ > +int odp_pktio_in_queues(odp_pktio_t pktio, odp_queue_t queues[], int num); > + > +/** > + * Direct packet input queues > + * > + * Returns the number of input queues configured for the interface in > + * ODP_PKTIN_MODE_RECV mode. Outputs up to 'num' queue handles when the > + * 'queues' array pointer is not NULL. If return value is larger than > 'num', > + * there are more queues than the function was allowed to output. > + * > + * Packets from these queues are received with odp_pktio_recv_queue(). > + * > + * @param pktio Packet IO handle > + * @param[out] queues Points to an array of queue handles for output > + * @param num Maximum number of queue handles to output > + * > + * @return Number of packet input queues > + * @retval <0 on failure > + */ > +int odp_pktio_pktin_queues(odp_pktio_t pktio, odp_pktin_queue_t queues[], > + int num); > + > +/** > * Start packet receive and transmit > * > * Activate packet receive and transmit on a previously opened or stopped > @@ -411,6 +535,15 @@ uint64_t odp_pktio_to_u64(odp_pktio_t pktio); > void odp_pktio_param_init(odp_pktio_param_t *param); > > /** > + * Initialize packet input queue parameters > + * > + * Initialize an odp_pktio_input_queue_param_t to its default values. > + * > + * @param param Input queue parameter structure to be initialized > + */ > +void odp_pktio_input_queue_param_init(odp_pktio_input_queue_param_t > *param); > + > +/** > * Print pktio info to the console > * > * Print implementation-defined pktio debug information to the console. > diff --git a/platform/linux-generic/include/odp/plat/packet_io_types.h > b/platform/linux-generic/include/odp/plat/packet_io_types.h > index 3cc64c6..2e229c3 100644 > --- a/platform/linux-generic/include/odp/plat/packet_io_types.h > +++ b/platform/linux-generic/include/odp/plat/packet_io_types.h > @@ -28,6 +28,8 @@ extern "C" { > > typedef ODP_HANDLE_T(odp_pktio_t); > > +typedef ODP_HANDLE_T(odp_pktin_queue_t); > + > > > > Should we also have an ODP_PKTIN_QUEUE_INVALID type value defined? > > > > Not needed yet. We can add it later if some API call needs it. Currently, > the only way to get those handles is through odp_pktio_pktin_queues(), > which returns to you how many (valid) handles it did write. There’s no need > for application to compare handles against invalid. > > > > -Petri > > > > #define ODP_PKTIO_INVALID _odp_cast_scalar(odp_pktio_t, 0) > > #define ODP_PKTIO_ANY _odp_cast_scalar(odp_pktio_t, ~0) > -- > 2.6.2 > > _______________________________________________ > lng-odp mailing list > [email protected] > https://lists.linaro.org/mailman/listinfo/lng-odp > > >
_______________________________________________ lng-odp mailing list [email protected] https://lists.linaro.org/mailman/listinfo/lng-odp
