From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id C734DF04 for ; Fri, 24 Nov 2017 10:39:25 +0100 (CET) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Nov 2017 01:39:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,446,1505804400"; d="scan'208";a="179996682" Received: from rnicolau-mobl.ger.corp.intel.com (HELO [10.237.221.73]) ([10.237.221.73]) by fmsmga006.fm.intel.com with ESMTP; 24 Nov 2017 01:39:22 -0800 To: Akhil Goyal , Anoob Joseph , Declan Doherty , Sergio Gonzalez Monroy Cc: Jerin Jacob , Narayana Prasad , dev@dpdk.org References: <1511333716-11955-1-git-send-email-anoob.joseph@caviumnetworks.com> <1511435969-5887-1-git-send-email-anoob.joseph@caviumnetworks.com> <1511435969-5887-2-git-send-email-anoob.joseph@caviumnetworks.com> From: Radu Nicolau Message-ID: <414c3491-7a54-09b4-0cde-a21bffaeb1ab@intel.com> Date: Fri, 24 Nov 2017 09:39:21 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Subject: Re: [dpdk-dev] [PATCH v3 1/2] lib/security: add support for get metadata X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Nov 2017 09:39:26 -0000 Hi, Comment inline On 11/24/2017 8:50 AM, Akhil Goyal wrote: > Hi Anoob, Radu, > On 11/23/2017 4:49 PM, Anoob Joseph wrote: >> In case of inline protocol processed ingress traffic, the packet may not >> have enough information to determine the security parameters with which >> the packet was processed. In such cases, application could get metadata >> from the packet which could be used to identify the security parameters >> with which the packet was processed. >> >> Signed-off-by: Anoob Joseph >> --- >> v3: >> * Replaced 64 bit metadata in conf with (void *)userdata >> * The API(rte_security_get_pkt_metadata) would return void * instead of >>    uint64_t >> >> v2: >> * Replaced get_session and get_cookie APIs with get_pkt_metadata API >> >>   lib/librte_security/rte_security.c        | 13 +++++++++++++ >>   lib/librte_security/rte_security.h        | 19 +++++++++++++++++++ >>   lib/librte_security/rte_security_driver.h | 16 ++++++++++++++++ >>   3 files changed, 48 insertions(+) >> >> diff --git a/lib/librte_security/rte_security.c >> b/lib/librte_security/rte_security.c >> index 1227fca..a1d78b6 100644 >> --- a/lib/librte_security/rte_security.c >> +++ b/lib/librte_security/rte_security.c >> @@ -108,6 +108,19 @@ rte_security_set_pkt_metadata(struct >> rte_security_ctx *instance, >>                              sess, m, params); >>   } >>   +void * >> +rte_security_get_pkt_metadata(struct rte_security_ctx *instance, >> +                  struct rte_mbuf *pkt) > Can we rename pkt with m. Just to make it consistent with the set API. >> +{ >> +    void *md = NULL; >> + >> + RTE_FUNC_PTR_OR_ERR_RET(*instance->ops->get_pkt_metadata, NULL); >> +    if (instance->ops->get_pkt_metadata(instance->device, pkt, &md)) >> +        return NULL; >> + >> +    return md; >> +} > > Pkt metadata should be set by user i.e. the application, and the > driver need not be aware of the format and the values of the metadata. > So setting the metadata in the driver and getting it back from the > driver does not look a good idea. > > Is it possible, that the application define the metadata on its own > and set it in the library itself without the call to the driver ops. I'm not sure I understand here; even in our case (ixgbe) the driver sets the metadata and it is aware of the format - that is the whole idea. This is why we added the set_metadata API, to allow the driver to inject extra information into the mbuf, information that is driver specific and derived from the security session, so it makes sense to also have a symmetric get_metadata. Private data is the one that follows those rules, i.e. application specific and driver transparent. > >> + >>   const struct rte_security_capability * >>   rte_security_capabilities_get(struct rte_security_ctx *instance) >>   { >> diff --git a/lib/librte_security/rte_security.h >> b/lib/librte_security/rte_security.h >> index 653929b..35c306a 100644 >> --- a/lib/librte_security/rte_security.h >> +++ b/lib/librte_security/rte_security.h >> @@ -274,6 +274,8 @@ struct rte_security_session_conf { >>       /**< Configuration parameters for security session */ >>       struct rte_crypto_sym_xform *crypto_xform; >>       /**< Security Session Crypto Transformations */ >> +    void *userdata; >> +    /**< Application specific metadata */ >>   }; >>     struct rte_security_session { >> @@ -346,6 +348,23 @@ rte_security_set_pkt_metadata(struct >> rte_security_ctx *instance, >>                     struct rte_mbuf *mb, void *params); >>     /** >> + * Get metadata from the packet. This returns metadata associated >> with the >> + * security session which processed the packet. >> + * >> + * This is valid only for inline processed ingress packets. >> + * >> + * @param   instance    security instance >> + * @param   pkt        packet mbuf >> + * >> + * @return >> + *  - On success, metadata >> + *  - On failure, NULL >> + */ >> +void * >> +rte_security_get_pkt_metadata(struct rte_security_ctx *instance, >> +                  struct rte_mbuf *pkt); >> + >> +/** >>    * Attach a session to a symmetric crypto operation >>    * >>    * @param    sym_op    crypto operation >> diff --git a/lib/librte_security/rte_security_driver.h >> b/lib/librte_security/rte_security_driver.h >> index 997fbe7..561ae83 100644 >> --- a/lib/librte_security/rte_security_driver.h >> +++ b/lib/librte_security/rte_security_driver.h >> @@ -122,6 +122,20 @@ typedef int (*security_set_pkt_metadata_t)(void >> *device, >>           void *params); >>     /** >> + * Get metadata from the packet. >> + * >> + * @param    device        Crypto/eth device pointer >> + * @param    pkt        Packet mbuf >> + * @param    mt        Pointer to receive metadata >> + * >> + * @return >> + *  - Returns 0 if metadata is retrieved successfully. >> + *  - Returns -ve value for errors. >> + */ >> +typedef int (*security_get_pkt_metadata_t)(void *device, >> +        struct rte_mbuf *pkt, void **md); >> + >> +/** >>    * Get security capabilities of the device. >>    * >>    * @param    device        crypto/eth device pointer >> @@ -145,6 +159,8 @@ struct rte_security_ops { >>       /**< Clear a security sessions private data. */ >>       security_set_pkt_metadata_t set_pkt_metadata; >>       /**< Update mbuf metadata. */ >> +    security_get_pkt_metadata_t get_pkt_metadata; >> +    /**< Get metadata from packet. */ >>       security_capabilities_get_t capabilities_get; >>       /**< Get security capabilities. */ >>   }; >> >