diff mbox

[ODP/PATCH,v6] API support for querying mac address

Message ID 1412612133-1497-1-git-send-email-bala.manoharan@linaro.org
State New
Headers show

Commit Message

Balasubramanian Manoharan Oct. 6, 2014, 4:15 p.m. UTC
This patch contains API support for querying mac address using odp_pktio_t handle
This patch incorporates the latest ODP_ERR and ODP_ABORT changes done in linux-generic repo

Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
---
 example/ipsec/odp_ipsec.c                          |  9 ++++++--
 platform/linux-generic/include/api/odp_packet_io.h | 17 +++++++++++++++
 platform/linux-generic/odp_packet_io.c             | 24 ++++++++++++++++++++++
 platform/linux-generic/odp_packet_socket.c         | 16 ++++++++++-----
 4 files changed, 59 insertions(+), 7 deletions(-)

Comments

Savolainen, Petri (NSN - FI/Espoo) Oct. 7, 2014, 7:13 a.m. UTC | #1
> -----Original Message-----
> From: lng-odp-bounces@lists.linaro.org [mailto:lng-odp-
> bounces@lists.linaro.org] On Behalf Of ext Balasubramanian Manoharan
> Sent: Monday, October 06, 2014 7:16 PM
> To: lng-odp@lists.linaro.org
> Subject: [lng-odp] [ODP/PATCH v6] API support for querying mac address
> 
> This patch contains API support for querying mac address using odp_pktio_t
> handle
> This patch incorporates the latest ODP_ERR and ODP_ABORT changes done in
> linux-generic repo
> 
> Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
> ---
>  example/ipsec/odp_ipsec.c                          |  9 ++++++--
>  platform/linux-generic/include/api/odp_packet_io.h | 17 +++++++++++++++
>  platform/linux-generic/odp_packet_io.c             | 24
> ++++++++++++++++++++++
>  platform/linux-generic/odp_packet_socket.c         | 16 ++++++++++-----
>  4 files changed, 59 insertions(+), 7 deletions(-)
> 
> diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
> index ec6c87a..9a46a0c 100644
> --- a/example/ipsec/odp_ipsec.c
> +++ b/example/ipsec/odp_ipsec.c
> @@ -549,7 +549,8 @@ void initialize_intf(char *intf)
>  	char inq_name[ODP_QUEUE_NAME_LEN];
>  	odp_queue_param_t qparam;
>  	int ret;
> -	uint8_t src_mac[ODPH_ETHADDR_LEN];
> +	uint8_t src_mac[ODP_MAC_ADDR_MAX_LENGTH];

I think a helper definition should be used here. I'd not include protocol definitions/types into the main ODP API. 


> +	size_t mac_addr_size;
>  	char src_mac_str[MAX_STRING];
> 
>  	/*
> @@ -587,8 +588,12 @@ void initialize_intf(char *intf)
>  	/* Read the source MAC address for this interface */
>  #if USE_MAC_ADDR_HACK
>  	ret = query_mac_address(intf, src_mac);
> +	(void)mac_addr_size;
>  #else
> -	ret = odp_pktio_get_mac_addr(pktio, src_mac);
> +	ret = odp_pktio_get_mac_addr(pktio, src_mac, &mac_addr_size);
> +	if (mac_addr_size != ODPH_ETHADDR_LEN) {
> +		ODP_ABORT("Ethernet mac address length not supported");
> +	}
>  #endif
>  	if (ret) {
>  		ODP_ERR("Error: failed during MAC address get for %s\n",
> intf);
> diff --git a/platform/linux-generic/include/api/odp_packet_io.h
> b/platform/linux-generic/include/api/odp_packet_io.h
> index 29fd105..2086316 100644
> --- a/platform/linux-generic/include/api/odp_packet_io.h
> +++ b/platform/linux-generic/include/api/odp_packet_io.h
> @@ -125,6 +125,23 @@ void odp_pktio_set_input(odp_packet_t pkt,
> odp_pktio_t id);
>   */
>  odp_pktio_t odp_pktio_get_input(odp_packet_t pkt);
> 
> +/**
> + * Defines the maximum length of mac address supported by this platform
> + */
> +#define ODP_MAC_ADDR_MAX_LENGTH	ETH_ALEN
> +
> +/**
> + * Get mac address of the interface
> + *
> + * @param id		ODP packet IO handle
> + * @param mac_addr	Storage for Mac address of the packet IO interface
> + *			Storage provided by the caller should be equal
> + *			to ODP_MAC_ADDR_MAX_LENGTH (filled by function)

"filled by function" ==> output parameter

> + * @param addr_size	Size of the Mac address (filled by function)

I think it would be more logical if this is input parameter (== sizeof(mac_addr)) and used for error checking. Function could return the number of bytes copied (6 or 8) on success (and 0 on failure). User should know beforehand how large MAC address to expect, right?

> + * @return  0 on success or -1 on error
> +**/
> +int odp_pktio_get_mac_addr(odp_pktio_t id, unsigned char *mac_addr,
> +			   size_t *addr_size);

To be inline with other accessor functions "get" should be dropped. What if an interface is configured to accept multiple mac addresses? Is this the default address (every interface should have at least one mac address). How other MACs are inquired? Or is it part of classification then.



-Petri
Balasubramanian Manoharan Oct. 7, 2014, 7:47 a.m. UTC | #2
On 7 October 2014 12:43, Savolainen, Petri (NSN - FI/Espoo) <
petri.savolainen@nsn.com> wrote:

>
>
> > -----Original Message-----
> > From: lng-odp-bounces@lists.linaro.org [mailto:lng-odp-
> > bounces@lists.linaro.org] On Behalf Of ext Balasubramanian Manoharan
> > Sent: Monday, October 06, 2014 7:16 PM
> > To: lng-odp@lists.linaro.org
> > Subject: [lng-odp] [ODP/PATCH v6] API support for querying mac address
> >
> > This patch contains API support for querying mac address using
> odp_pktio_t
> > handle
> > This patch incorporates the latest ODP_ERR and ODP_ABORT changes done in
> > linux-generic repo
> >
> > Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
> > ---
> >  example/ipsec/odp_ipsec.c                          |  9 ++++++--
> >  platform/linux-generic/include/api/odp_packet_io.h | 17 +++++++++++++++
> >  platform/linux-generic/odp_packet_io.c             | 24
> > ++++++++++++++++++++++
> >  platform/linux-generic/odp_packet_socket.c         | 16 ++++++++++-----
> >  4 files changed, 59 insertions(+), 7 deletions(-)
> >
> > diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
> > index ec6c87a..9a46a0c 100644
> > --- a/example/ipsec/odp_ipsec.c
> > +++ b/example/ipsec/odp_ipsec.c
> > @@ -549,7 +549,8 @@ void initialize_intf(char *intf)
> >       char inq_name[ODP_QUEUE_NAME_LEN];
> >       odp_queue_param_t qparam;
> >       int ret;
> > -     uint8_t src_mac[ODPH_ETHADDR_LEN];
> > +     uint8_t src_mac[ODP_MAC_ADDR_MAX_LENGTH];
>
> I think a helper definition should be used here. I'd not include protocol
> definitions/types into the main ODP API.
>
I wanted a design to help the platform decide the maximum size of MAC_ADDR
supported. Any approach is fine.

>
>
> > +     size_t mac_addr_size;
> >       char src_mac_str[MAX_STRING];
> >
> >       /*
> > @@ -587,8 +588,12 @@ void initialize_intf(char *intf)
> >       /* Read the source MAC address for this interface */
> >  #if USE_MAC_ADDR_HACK
> >       ret = query_mac_address(intf, src_mac);
> > +     (void)mac_addr_size;
> >  #else
> > -     ret = odp_pktio_get_mac_addr(pktio, src_mac);
> > +     ret = odp_pktio_get_mac_addr(pktio, src_mac, &mac_addr_size);
> > +     if (mac_addr_size != ODPH_ETHADDR_LEN) {
> > +             ODP_ABORT("Ethernet mac address length not supported");
> > +     }
> >  #endif
> >       if (ret) {
> >               ODP_ERR("Error: failed during MAC address get for %s\n",
> > intf);
> > diff --git a/platform/linux-generic/include/api/odp_packet_io.h
> > b/platform/linux-generic/include/api/odp_packet_io.h
> > index 29fd105..2086316 100644
> > --- a/platform/linux-generic/include/api/odp_packet_io.h
> > +++ b/platform/linux-generic/include/api/odp_packet_io.h
> > @@ -125,6 +125,23 @@ void odp_pktio_set_input(odp_packet_t pkt,
> > odp_pktio_t id);
> >   */
> >  odp_pktio_t odp_pktio_get_input(odp_packet_t pkt);
> >
> > +/**
> > + * Defines the maximum length of mac address supported by this platform
> > + */
> > +#define ODP_MAC_ADDR_MAX_LENGTH      ETH_ALEN
> > +
> > +/**
> > + * Get mac address of the interface
> > + *
> > + * @param id         ODP packet IO handle
> > + * @param mac_addr   Storage for Mac address of the packet IO interface
> > + *                   Storage provided by the caller should be equal
> > + *                   to ODP_MAC_ADDR_MAX_LENGTH (filled by function)
>
> "filled by function" ==> output parameter
>
> > + * @param addr_size  Size of the Mac address (filled by function)
>
> I think it would be more logical if this is input parameter (==
> sizeof(mac_addr)) and used for error checking. Function could return the
> number of bytes copied (6 or 8) on success (and 0 on failure). User should
> know beforehand how large MAC address to expect, right?
>
> I believe having the maximum MAC_ADDR length being defined by the platform
makes the application agnostic across different platform implementations
and different types of odp_pktio_t instances.
Having the size being returned as a parameter seemed to be more inline with
current ODP API design.


> > + * @return  0 on success or -1 on error
> > +**/
> > +int odp_pktio_get_mac_addr(odp_pktio_t id, unsigned char *mac_addr,
> > +                        size_t *addr_size);
>
> To be inline with other accessor functions "get" should be dropped. What
> if an interface is configured to accept multiple mac addresses? Is this the
> default address (every interface should have at least one mac address). How
> other MACs are inquired? Or is it part of classification then.
>
> This API would return the default MAC addr of the instance.
Returning multiple mac addr which was assigned to a specific interface
could be done by classification.

Regards,
Bala

>
>
> -Petri
>
Maxim Uvarov Oct. 8, 2014, 5:08 p.m. UTC | #3
On 10/07/2014 11:47 AM, Bala Manoharan wrote:
>
>
> On 7 October 2014 12:43, Savolainen, Petri (NSN - FI/Espoo) 
> <petri.savolainen@nsn.com <mailto:petri.savolainen@nsn.com>> wrote:
>
>
>
>     > -----Original Message-----
>     > From: lng-odp-bounces@lists.linaro.org
>     <mailto:lng-odp-bounces@lists.linaro.org> [mailto:lng-odp-
>     <mailto:lng-odp->
>     > bounces@lists.linaro.org <mailto:bounces@lists.linaro.org>] On
>     Behalf Of ext Balasubramanian Manoharan
>     > Sent: Monday, October 06, 2014 7:16 PM
>     > To: lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>     > Subject: [lng-odp] [ODP/PATCH v6] API support for querying mac
>     address
>     >
>     > This patch contains API support for querying mac address using
>     odp_pktio_t
>     > handle
>     > This patch incorporates the latest ODP_ERR and ODP_ABORT changes
>     done in
>     > linux-generic repo
>     >
>     > Signed-off-by: Balasubramanian Manoharan
>     <bala.manoharan@linaro.org <mailto:bala.manoharan@linaro.org>>
>     > ---
>     >  example/ipsec/odp_ipsec.c   |  9 ++++++--
>     > platform/linux-generic/include/api/odp_packet_io.h | 17
>     +++++++++++++++
>     >  platform/linux-generic/odp_packet_io.c    | 24
>     > ++++++++++++++++++++++
>     >  platform/linux-generic/odp_packet_socket.c    | 16 ++++++++++-----
>     >  4 files changed, 59 insertions(+), 7 deletions(-)
>     >
>     > diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
>     > index ec6c87a..9a46a0c 100644
>     > --- a/example/ipsec/odp_ipsec.c
>     > +++ b/example/ipsec/odp_ipsec.c
>     > @@ -549,7 +549,8 @@ void initialize_intf(char *intf)
>     >       char inq_name[ODP_QUEUE_NAME_LEN];
>     >       odp_queue_param_t qparam;
>     >       int ret;
>     > -     uint8_t src_mac[ODPH_ETHADDR_LEN];
>     > +     uint8_t src_mac[ODP_MAC_ADDR_MAX_LENGTH];
>
>     I think a helper definition should be used here. I'd not include
>     protocol definitions/types into the main ODP API.
>
> I wanted a design to help the platform decide the maximum size of 
> MAC_ADDR supported. Any approach is fine.
>
>
>
>     > +     size_t mac_addr_size;
>     >       char src_mac_str[MAX_STRING];
>     >
>     >       /*
>     > @@ -587,8 +588,12 @@ void initialize_intf(char *intf)
>     >       /* Read the source MAC address for this interface */
>     >  #if USE_MAC_ADDR_HACK
>     >       ret = query_mac_address(intf, src_mac);
>     > +     (void)mac_addr_size;
>     >  #else
>     > -     ret = odp_pktio_get_mac_addr(pktio, src_mac);
>     > +     ret = odp_pktio_get_mac_addr(pktio, src_mac, &mac_addr_size);
>     > +     if (mac_addr_size != ODPH_ETHADDR_LEN) {
>     > +             ODP_ABORT("Ethernet mac address length not
>     supported");
>     > +     }
>     >  #endif
>     >       if (ret) {
>     >               ODP_ERR("Error: failed during MAC address get for
>     %s\n",
>     > intf);
>     > diff --git a/platform/linux-generic/include/api/odp_packet_io.h
>     > b/platform/linux-generic/include/api/odp_packet_io.h
>     > index 29fd105..2086316 100644
>     > --- a/platform/linux-generic/include/api/odp_packet_io.h
>     > +++ b/platform/linux-generic/include/api/odp_packet_io.h
>     > @@ -125,6 +125,23 @@ void odp_pktio_set_input(odp_packet_t pkt,
>     > odp_pktio_t id);
>     >   */
>     >  odp_pktio_t odp_pktio_get_input(odp_packet_t pkt);
>     >
>     > +/**
>     > + * Defines the maximum length of mac address supported by this
>     platform
>     > + */
>     > +#define ODP_MAC_ADDR_MAX_LENGTH      ETH_ALEN
>     > +
>     > +/**
>     > + * Get mac address of the interface
>     > + *
>     > + * @param id         ODP packet IO handle
>     > + * @param mac_addr   Storage for Mac address of the packet IO
>     interface
>     > + *                   Storage provided by the caller should be equal
>     > + *                   to ODP_MAC_ADDR_MAX_LENGTH (filled by
>     function)
>
>     "filled by function" ==> output parameter
>
>     > + * @param addr_size  Size of the Mac address (filled by function)
>
>     I think it would be more logical if this is input parameter (==
>     sizeof(mac_addr)) and used for error checking. Function could
>     return the number of bytes copied (6 or 8) on success (and 0 on
>     failure). User should know beforehand how large MAC address to
>     expect, right?
>
> I believe having the maximum MAC_ADDR length being defined by the 
> platform makes the application agnostic across different platform 
> implementations and different types of odp_pktio_t instances.
> Having the size being returned as a parameter seemed to be more inline 
> with current ODP API design.
>

Can mac addr be different size? I saw only 6 bytes macs. Not sure if it 
can be different size. And if it can not be than we don't need 
ODP_MAC_ADDR_MAX_LENGTH.

Maxim.

>     > + * @return  0 on success or -1 on error
>     > +**/
>     > +int odp_pktio_get_mac_addr(odp_pktio_t id, unsigned char *mac_addr,
>     > +                        size_t *addr_size);
>
>     To be inline with other accessor functions "get" should be
>     dropped. What if an interface is configured to accept multiple mac
>     addresses? Is this the default address (every interface should
>     have at least one mac address). How other MACs are inquired? Or is
>     it part of classification then.
>
> This API would return the default MAC addr of the instance.
> Returning multiple mac addr which was assigned to a specific interface 
> could be done by classification.
>
> Regards,
> Bala
>
>
>
>     -Petri
>
>
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
Bill Fischofer Oct. 8, 2014, 5:28 p.m. UTC | #4
A MAC address (formerly MAC-48, now EUI-48) is always 6 bytes  The "full
form" is EUI-64, which is 8 byes.  See this article
<http://en.wikipedia.org/wiki/MAC_address> for details.

Bill

On Wed, Oct 8, 2014 at 12:08 PM, Maxim Uvarov <maxim.uvarov@linaro.org>
wrote:

> On 10/07/2014 11:47 AM, Bala Manoharan wrote:
>
>>
>>
>> On 7 October 2014 12:43, Savolainen, Petri (NSN - FI/Espoo) <
>> petri.savolainen@nsn.com <mailto:petri.savolainen@nsn.com>> wrote:
>>
>>
>>
>>     > -----Original Message-----
>>     > From: lng-odp-bounces@lists.linaro.org
>>     <mailto:lng-odp-bounces@lists.linaro.org> [mailto:lng-odp-
>>     <mailto:lng-odp->
>>     > bounces@lists.linaro.org <mailto:bounces@lists.linaro.org>] On
>>     Behalf Of ext Balasubramanian Manoharan
>>     > Sent: Monday, October 06, 2014 7:16 PM
>>     > To: lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>>     > Subject: [lng-odp] [ODP/PATCH v6] API support for querying mac
>>     address
>>     >
>>     > This patch contains API support for querying mac address using
>>     odp_pktio_t
>>     > handle
>>     > This patch incorporates the latest ODP_ERR and ODP_ABORT changes
>>     done in
>>     > linux-generic repo
>>     >
>>     > Signed-off-by: Balasubramanian Manoharan
>>     <bala.manoharan@linaro.org <mailto:bala.manoharan@linaro.org>>
>>
>>     > ---
>>     >  example/ipsec/odp_ipsec.c   |  9 ++++++--
>>     > platform/linux-generic/include/api/odp_packet_io.h | 17
>>     +++++++++++++++
>>     >  platform/linux-generic/odp_packet_io.c    | 24
>>     > ++++++++++++++++++++++
>>     >  platform/linux-generic/odp_packet_socket.c    | 16 ++++++++++-----
>>     >  4 files changed, 59 insertions(+), 7 deletions(-)
>>     >
>>     > diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
>>     > index ec6c87a..9a46a0c 100644
>>     > --- a/example/ipsec/odp_ipsec.c
>>     > +++ b/example/ipsec/odp_ipsec.c
>>     > @@ -549,7 +549,8 @@ void initialize_intf(char *intf)
>>     >       char inq_name[ODP_QUEUE_NAME_LEN];
>>     >       odp_queue_param_t qparam;
>>     >       int ret;
>>     > -     uint8_t src_mac[ODPH_ETHADDR_LEN];
>>     > +     uint8_t src_mac[ODP_MAC_ADDR_MAX_LENGTH];
>>
>>     I think a helper definition should be used here. I'd not include
>>     protocol definitions/types into the main ODP API.
>>
>> I wanted a design to help the platform decide the maximum size of
>> MAC_ADDR supported. Any approach is fine.
>>
>>
>>
>>     > +     size_t mac_addr_size;
>>     >       char src_mac_str[MAX_STRING];
>>     >
>>     >       /*
>>     > @@ -587,8 +588,12 @@ void initialize_intf(char *intf)
>>     >       /* Read the source MAC address for this interface */
>>     >  #if USE_MAC_ADDR_HACK
>>     >       ret = query_mac_address(intf, src_mac);
>>     > +     (void)mac_addr_size;
>>     >  #else
>>     > -     ret = odp_pktio_get_mac_addr(pktio, src_mac);
>>     > +     ret = odp_pktio_get_mac_addr(pktio, src_mac, &mac_addr_size);
>>     > +     if (mac_addr_size != ODPH_ETHADDR_LEN) {
>>     > +             ODP_ABORT("Ethernet mac address length not
>>     supported");
>>     > +     }
>>     >  #endif
>>     >       if (ret) {
>>     >               ODP_ERR("Error: failed during MAC address get for
>>     %s\n",
>>     > intf);
>>     > diff --git a/platform/linux-generic/include/api/odp_packet_io.h
>>     > b/platform/linux-generic/include/api/odp_packet_io.h
>>     > index 29fd105..2086316 100644
>>     > --- a/platform/linux-generic/include/api/odp_packet_io.h
>>     > +++ b/platform/linux-generic/include/api/odp_packet_io.h
>>     > @@ -125,6 +125,23 @@ void odp_pktio_set_input(odp_packet_t pkt,
>>     > odp_pktio_t id);
>>     >   */
>>     >  odp_pktio_t odp_pktio_get_input(odp_packet_t pkt);
>>     >
>>     > +/**
>>     > + * Defines the maximum length of mac address supported by this
>>     platform
>>     > + */
>>     > +#define ODP_MAC_ADDR_MAX_LENGTH      ETH_ALEN
>>     > +
>>     > +/**
>>     > + * Get mac address of the interface
>>     > + *
>>     > + * @param id         ODP packet IO handle
>>     > + * @param mac_addr   Storage for Mac address of the packet IO
>>     interface
>>     > + *                   Storage provided by the caller should be equal
>>     > + *                   to ODP_MAC_ADDR_MAX_LENGTH (filled by
>>     function)
>>
>>     "filled by function" ==> output parameter
>>
>>     > + * @param addr_size  Size of the Mac address (filled by function)
>>
>>     I think it would be more logical if this is input parameter (==
>>     sizeof(mac_addr)) and used for error checking. Function could
>>     return the number of bytes copied (6 or 8) on success (and 0 on
>>     failure). User should know beforehand how large MAC address to
>>     expect, right?
>>
>> I believe having the maximum MAC_ADDR length being defined by the
>> platform makes the application agnostic across different platform
>> implementations and different types of odp_pktio_t instances.
>> Having the size being returned as a parameter seemed to be more inline
>> with current ODP API design.
>>
>>
> Can mac addr be different size? I saw only 6 bytes macs. Not sure if it
> can be different size. And if it can not be than we don't need
> ODP_MAC_ADDR_MAX_LENGTH.
>
> Maxim.
>
>      > + * @return  0 on success or -1 on error
>>     > +**/
>>     > +int odp_pktio_get_mac_addr(odp_pktio_t id, unsigned char
>> *mac_addr,
>>     > +                        size_t *addr_size);
>>
>>     To be inline with other accessor functions "get" should be
>>     dropped. What if an interface is configured to accept multiple mac
>>     addresses? Is this the default address (every interface should
>>     have at least one mac address). How other MACs are inquired? Or is
>>     it part of classification then.
>>
>> This API would return the default MAC addr of the instance.
>> Returning multiple mac addr which was assigned to a specific interface
>> could be done by classification.
>>
>> Regards,
>> Bala
>>
>>
>>
>>     -Petri
>>
>>
>>
>>
>> _______________________________________________
>> lng-odp mailing list
>> lng-odp@lists.linaro.org
>> http://lists.linaro.org/mailman/listinfo/lng-odp
>>
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
Maxim Uvarov Oct. 8, 2014, 5:42 p.m. UTC | #5
On 10/08/2014 09:28 PM, Bill Fischofer wrote:
> A MAC address (formerly MAC-48, now EUI-48) is always 6 bytes  The 
> "full form" is EUI-64, which is 8 byes.  See this article 
> <http://en.wikipedia.org/wiki/MAC_address> for details.
>
> Bill

Thanks! I forgot about ipv6 and Google :) Didn't know that it's possible 
to write so many words about MAC :) Article is really interesting.

Maxim.

>
> On Wed, Oct 8, 2014 at 12:08 PM, Maxim Uvarov <maxim.uvarov@linaro.org 
> <mailto:maxim.uvarov@linaro.org>> wrote:
>
>     On 10/07/2014 11:47 AM, Bala Manoharan wrote:
>
>
>
>         On 7 October 2014 12:43, Savolainen, Petri (NSN - FI/Espoo)
>         <petri.savolainen@nsn.com <mailto:petri.savolainen@nsn.com>
>         <mailto:petri.savolainen@nsn.com
>         <mailto:petri.savolainen@nsn.com>>> wrote:
>
>
>
>             > -----Original Message-----
>             > From: lng-odp-bounces@lists.linaro.org
>         <mailto:lng-odp-bounces@lists.linaro.org>
>             <mailto:lng-odp-bounces@lists.linaro.org
>         <mailto:lng-odp-bounces@lists.linaro.org>> [mailto:lng-odp-
>         <mailto:lng-odp->
>             <mailto:lng-odp- <mailto:lng-odp->>
>             > bounces@lists.linaro.org
>         <mailto:bounces@lists.linaro.org>
>         <mailto:bounces@lists.linaro.org
>         <mailto:bounces@lists.linaro.org>>] On
>             Behalf Of ext Balasubramanian Manoharan
>             > Sent: Monday, October 06, 2014 7:16 PM
>             > To: lng-odp@lists.linaro.org
>         <mailto:lng-odp@lists.linaro.org>
>         <mailto:lng-odp@lists.linaro.org
>         <mailto:lng-odp@lists.linaro.org>>
>             > Subject: [lng-odp] [ODP/PATCH v6] API support for
>         querying mac
>             address
>             >
>             > This patch contains API support for querying mac address
>         using
>             odp_pktio_t
>             > handle
>             > This patch incorporates the latest ODP_ERR and ODP_ABORT
>         changes
>             done in
>             > linux-generic repo
>             >
>             > Signed-off-by: Balasubramanian Manoharan
>             <bala.manoharan@linaro.org
>         <mailto:bala.manoharan@linaro.org>
>         <mailto:bala.manoharan@linaro.org
>         <mailto:bala.manoharan@linaro.org>>>
>
>             > ---
>             >  example/ipsec/odp_ipsec.c   |  9 ++++++--
>             > platform/linux-generic/include/api/odp_packet_io.h | 17
>             +++++++++++++++
>             >  platform/linux-generic/odp_packet_io.c    | 24
>             > ++++++++++++++++++++++
>             >  platform/linux-generic/odp_packet_socket.c   | 16
>         ++++++++++-----
>             >  4 files changed, 59 insertions(+), 7 deletions(-)
>             >
>             > diff --git a/example/ipsec/odp_ipsec.c
>         b/example/ipsec/odp_ipsec.c
>             > index ec6c87a..9a46a0c 100644
>             > --- a/example/ipsec/odp_ipsec.c
>             > +++ b/example/ipsec/odp_ipsec.c
>             > @@ -549,7 +549,8 @@ void initialize_intf(char *intf)
>             >       char inq_name[ODP_QUEUE_NAME_LEN];
>             >       odp_queue_param_t qparam;
>             >       int ret;
>             > -     uint8_t src_mac[ODPH_ETHADDR_LEN];
>             > +     uint8_t src_mac[ODP_MAC_ADDR_MAX_LENGTH];
>
>             I think a helper definition should be used here. I'd not
>         include
>             protocol definitions/types into the main ODP API.
>
>         I wanted a design to help the platform decide the maximum size
>         of MAC_ADDR supported. Any approach is fine.
>
>
>
>             > +     size_t mac_addr_size;
>             >       char src_mac_str[MAX_STRING];
>             >
>             >       /*
>             > @@ -587,8 +588,12 @@ void initialize_intf(char *intf)
>             >       /* Read the source MAC address for this interface */
>             >  #if USE_MAC_ADDR_HACK
>             >       ret = query_mac_address(intf, src_mac);
>             > +     (void)mac_addr_size;
>             >  #else
>             > -     ret = odp_pktio_get_mac_addr(pktio, src_mac);
>             > +     ret = odp_pktio_get_mac_addr(pktio, src_mac,
>         &mac_addr_size);
>             > +     if (mac_addr_size != ODPH_ETHADDR_LEN) {
>             > +             ODP_ABORT("Ethernet mac address length not
>             supported");
>             > +     }
>             >  #endif
>             >       if (ret) {
>             >               ODP_ERR("Error: failed during MAC address
>         get for
>             %s\n",
>             > intf);
>             > diff --git
>         a/platform/linux-generic/include/api/odp_packet_io.h
>             > b/platform/linux-generic/include/api/odp_packet_io.h
>             > index 29fd105..2086316 100644
>             > --- a/platform/linux-generic/include/api/odp_packet_io.h
>             > +++ b/platform/linux-generic/include/api/odp_packet_io.h
>             > @@ -125,6 +125,23 @@ void
>         odp_pktio_set_input(odp_packet_t pkt,
>             > odp_pktio_t id);
>             >   */
>             >  odp_pktio_t odp_pktio_get_input(odp_packet_t pkt);
>             >
>             > +/**
>             > + * Defines the maximum length of mac address supported
>         by this
>             platform
>             > + */
>             > +#define ODP_MAC_ADDR_MAX_LENGTH ETH_ALEN
>             > +
>             > +/**
>             > + * Get mac address of the interface
>             > + *
>             > + * @param id         ODP packet IO handle
>             > + * @param mac_addr   Storage for Mac address of the
>         packet IO
>             interface
>             > + *                   Storage provided by the caller
>         should be equal
>             > + *                   to ODP_MAC_ADDR_MAX_LENGTH (filled by
>             function)
>
>             "filled by function" ==> output parameter
>
>             > + * @param addr_size  Size of the Mac address (filled by
>         function)
>
>             I think it would be more logical if this is input
>         parameter (==
>             sizeof(mac_addr)) and used for error checking. Function could
>             return the number of bytes copied (6 or 8) on success (and
>         0 on
>             failure). User should know beforehand how large MAC address to
>             expect, right?
>
>         I believe having the maximum MAC_ADDR length being defined by
>         the platform makes the application agnostic across different
>         platform implementations and different types of odp_pktio_t
>         instances.
>         Having the size being returned as a parameter seemed to be
>         more inline with current ODP API design.
>
>
>     Can mac addr be different size? I saw only 6 bytes macs. Not sure
>     if it can be different size. And if it can not be than we don't
>     need ODP_MAC_ADDR_MAX_LENGTH.
>
>     Maxim.
>
>             > + * @return  0 on success or -1 on error
>             > +**/
>             > +int odp_pktio_get_mac_addr(odp_pktio_t id, unsigned
>         char *mac_addr,
>             > +                        size_t *addr_size);
>
>             To be inline with other accessor functions "get" should be
>             dropped. What if an interface is configured to accept
>         multiple mac
>             addresses? Is this the default address (every interface should
>             have at least one mac address). How other MACs are
>         inquired? Or is
>             it part of classification then.
>
>         This API would return the default MAC addr of the instance.
>         Returning multiple mac addr which was assigned to a specific
>         interface could be done by classification.
>
>         Regards,
>         Bala
>
>
>
>             -Petri
>
>
>
>
>         _______________________________________________
>         lng-odp mailing list
>         lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>         http://lists.linaro.org/mailman/listinfo/lng-odp
>
>
>
>     _______________________________________________
>     lng-odp mailing list
>     lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>     http://lists.linaro.org/mailman/listinfo/lng-odp
>
>
Ola Liljedahl Oct. 9, 2014, 10:24 a.m. UTC | #6
Some interface types use 64-bit MAC addresses (e.g. Firewire).

I think the ODP API should specify a recommended buffer size (e.g. #define
ODP_MACADDR_SIZE 8) and then return the actual length of the return MAC
address.
The application passes a buffer and a buffer size (this could be 6 if the
application is sure that the interface uses a MAC48 address). If the buffer
size is too small for the actual MAC address, an error is returned (e.g.
-1).

-- Ola


On 8 October 2014 19:08, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:

> On 10/07/2014 11:47 AM, Bala Manoharan wrote:
>
>>
>>
>> On 7 October 2014 12:43, Savolainen, Petri (NSN - FI/Espoo) <
>> petri.savolainen@nsn.com <mailto:petri.savolainen@nsn.com>> wrote:
>>
>>
>>
>>     > -----Original Message-----
>>     > From: lng-odp-bounces@lists.linaro.org
>>     <mailto:lng-odp-bounces@lists.linaro.org> [mailto:lng-odp-
>>     <mailto:lng-odp->
>>     > bounces@lists.linaro.org <mailto:bounces@lists.linaro.org>] On
>>     Behalf Of ext Balasubramanian Manoharan
>>     > Sent: Monday, October 06, 2014 7:16 PM
>>     > To: lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>>     > Subject: [lng-odp] [ODP/PATCH v6] API support for querying mac
>>     address
>>     >
>>     > This patch contains API support for querying mac address using
>>     odp_pktio_t
>>     > handle
>>     > This patch incorporates the latest ODP_ERR and ODP_ABORT changes
>>     done in
>>     > linux-generic repo
>>     >
>>     > Signed-off-by: Balasubramanian Manoharan
>>     <bala.manoharan@linaro.org <mailto:bala.manoharan@linaro.org>>
>>     > ---
>>     >  example/ipsec/odp_ipsec.c   |  9 ++++++--
>>     > platform/linux-generic/include/api/odp_packet_io.h | 17
>>     +++++++++++++++
>>     >  platform/linux-generic/odp_packet_io.c    | 24
>>     > ++++++++++++++++++++++
>>     >  platform/linux-generic/odp_packet_socket.c    | 16 ++++++++++-----
>>     >  4 files changed, 59 insertions(+), 7 deletions(-)
>>     >
>>     > diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
>>     > index ec6c87a..9a46a0c 100644
>>     > --- a/example/ipsec/odp_ipsec.c
>>     > +++ b/example/ipsec/odp_ipsec.c
>>     > @@ -549,7 +549,8 @@ void initialize_intf(char *intf)
>>     >       char inq_name[ODP_QUEUE_NAME_LEN];
>>     >       odp_queue_param_t qparam;
>>     >       int ret;
>>     > -     uint8_t src_mac[ODPH_ETHADDR_LEN];
>>     > +     uint8_t src_mac[ODP_MAC_ADDR_MAX_LENGTH];
>>
>>     I think a helper definition should be used here. I'd not include
>>     protocol definitions/types into the main ODP API.
>>
>> I wanted a design to help the platform decide the maximum size of
>> MAC_ADDR supported. Any approach is fine.
>>
>>
>>
>>     > +     size_t mac_addr_size;
>>     >       char src_mac_str[MAX_STRING];
>>     >
>>     >       /*
>>     > @@ -587,8 +588,12 @@ void initialize_intf(char *intf)
>>     >       /* Read the source MAC address for this interface */
>>     >  #if USE_MAC_ADDR_HACK
>>     >       ret = query_mac_address(intf, src_mac);
>>     > +     (void)mac_addr_size;
>>     >  #else
>>     > -     ret = odp_pktio_get_mac_addr(pktio, src_mac);
>>     > +     ret = odp_pktio_get_mac_addr(pktio, src_mac, &mac_addr_size);
>>     > +     if (mac_addr_size != ODPH_ETHADDR_LEN) {
>>     > +             ODP_ABORT("Ethernet mac address length not
>>     supported");
>>     > +     }
>>     >  #endif
>>     >       if (ret) {
>>     >               ODP_ERR("Error: failed during MAC address get for
>>     %s\n",
>>     > intf);
>>     > diff --git a/platform/linux-generic/include/api/odp_packet_io.h
>>     > b/platform/linux-generic/include/api/odp_packet_io.h
>>     > index 29fd105..2086316 100644
>>     > --- a/platform/linux-generic/include/api/odp_packet_io.h
>>     > +++ b/platform/linux-generic/include/api/odp_packet_io.h
>>     > @@ -125,6 +125,23 @@ void odp_pktio_set_input(odp_packet_t pkt,
>>     > odp_pktio_t id);
>>     >   */
>>     >  odp_pktio_t odp_pktio_get_input(odp_packet_t pkt);
>>     >
>>     > +/**
>>     > + * Defines the maximum length of mac address supported by this
>>     platform
>>     > + */
>>     > +#define ODP_MAC_ADDR_MAX_LENGTH      ETH_ALEN
>>     > +
>>     > +/**
>>     > + * Get mac address of the interface
>>     > + *
>>     > + * @param id         ODP packet IO handle
>>     > + * @param mac_addr   Storage for Mac address of the packet IO
>>     interface
>>     > + *                   Storage provided by the caller should be equal
>>     > + *                   to ODP_MAC_ADDR_MAX_LENGTH (filled by
>>     function)
>>
>>     "filled by function" ==> output parameter
>>
>>     > + * @param addr_size  Size of the Mac address (filled by function)
>>
>>     I think it would be more logical if this is input parameter (==
>>     sizeof(mac_addr)) and used for error checking. Function could
>>     return the number of bytes copied (6 or 8) on success (and 0 on
>>     failure). User should know beforehand how large MAC address to
>>     expect, right?
>>
>> I believe having the maximum MAC_ADDR length being defined by the
>> platform makes the application agnostic across different platform
>> implementations and different types of odp_pktio_t instances.
>> Having the size being returned as a parameter seemed to be more inline
>> with current ODP API design.
>>
>>
> Can mac addr be different size? I saw only 6 bytes macs. Not sure if it
> can be different size. And if it can not be than we don't need
> ODP_MAC_ADDR_MAX_LENGTH.
>
> Maxim.
>
>      > + * @return  0 on success or -1 on error
>>     > +**/
>>     > +int odp_pktio_get_mac_addr(odp_pktio_t id, unsigned char
>> *mac_addr,
>>     > +                        size_t *addr_size);
>>
>>     To be inline with other accessor functions "get" should be
>>     dropped. What if an interface is configured to accept multiple mac
>>     addresses? Is this the default address (every interface should
>>     have at least one mac address). How other MACs are inquired? Or is
>>     it part of classification then.
>>
>> This API would return the default MAC addr of the instance.
>> Returning multiple mac addr which was assigned to a specific interface
>> could be done by classification.
>>
>> Regards,
>> Bala
>>
>>
>>
>>     -Petri
>>
>>
>>
>>
>> _______________________________________________
>> lng-odp mailing list
>> lng-odp@lists.linaro.org
>> http://lists.linaro.org/mailman/listinfo/lng-odp
>>
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
Maxim Uvarov Oct. 9, 2014, 3:42 p.m. UTC | #7
On 10/09/2014 02:24 PM, Ola Liljedahl wrote:
> Some interface types use 64-bit MAC addresses (e.g. Firewire).
>
> I think the ODP API should specify a recommended buffer size (e.g. 
> #define ODP_MACADDR_SIZE 8) and then return the actual length of the 
> return MAC address.
> The application passes a buffer and a buffer size (this could be 6 if 
> the application is sure that the interface uses a MAC48 address). If 
> the buffer size is too small for the actual MAC address, an error is 
> returned (e.g. -1).
>
> -- Ola
>

ETH_ALEN is 6. So looks like patch needed to be update.

Maxim.


>
> On 8 October 2014 19:08, Maxim Uvarov <maxim.uvarov@linaro.org 
> <mailto:maxim.uvarov@linaro.org>> wrote:
>
>     On 10/07/2014 11:47 AM, Bala Manoharan wrote:
>
>
>
>         On 7 October 2014 12:43, Savolainen, Petri (NSN - FI/Espoo)
>         <petri.savolainen@nsn.com <mailto:petri.savolainen@nsn.com>
>         <mailto:petri.savolainen@nsn.com
>         <mailto:petri.savolainen@nsn.com>>> wrote:
>
>
>
>             > -----Original Message-----
>             > From: lng-odp-bounces@lists.linaro.org
>         <mailto:lng-odp-bounces@lists.linaro.org>
>             <mailto:lng-odp-bounces@lists.linaro.org
>         <mailto:lng-odp-bounces@lists.linaro.org>> [mailto:lng-odp-
>         <mailto:lng-odp->
>             <mailto:lng-odp- <mailto:lng-odp->>
>             > bounces@lists.linaro.org
>         <mailto:bounces@lists.linaro.org>
>         <mailto:bounces@lists.linaro.org
>         <mailto:bounces@lists.linaro.org>>] On
>             Behalf Of ext Balasubramanian Manoharan
>             > Sent: Monday, October 06, 2014 7:16 PM
>             > To: lng-odp@lists.linaro.org
>         <mailto:lng-odp@lists.linaro.org>
>         <mailto:lng-odp@lists.linaro.org
>         <mailto:lng-odp@lists.linaro.org>>
>             > Subject: [lng-odp] [ODP/PATCH v6] API support for
>         querying mac
>             address
>             >
>             > This patch contains API support for querying mac address
>         using
>             odp_pktio_t
>             > handle
>             > This patch incorporates the latest ODP_ERR and ODP_ABORT
>         changes
>             done in
>             > linux-generic repo
>             >
>             > Signed-off-by: Balasubramanian Manoharan
>             <bala.manoharan@linaro.org
>         <mailto:bala.manoharan@linaro.org>
>         <mailto:bala.manoharan@linaro.org
>         <mailto:bala.manoharan@linaro.org>>>
>             > ---
>             >  example/ipsec/odp_ipsec.c   |  9 ++++++--
>             > platform/linux-generic/include/api/odp_packet_io.h | 17
>             +++++++++++++++
>             >  platform/linux-generic/odp_packet_io.c    | 24
>             > ++++++++++++++++++++++
>             >  platform/linux-generic/odp_packet_socket.c    | 16
>         ++++++++++-----
>             >  4 files changed, 59 insertions(+), 7 deletions(-)
>             >
>             > diff --git a/example/ipsec/odp_ipsec.c
>         b/example/ipsec/odp_ipsec.c
>             > index ec6c87a..9a46a0c 100644
>             > --- a/example/ipsec/odp_ipsec.c
>             > +++ b/example/ipsec/odp_ipsec.c
>             > @@ -549,7 +549,8 @@ void initialize_intf(char *intf)
>             >       char inq_name[ODP_QUEUE_NAME_LEN];
>             >       odp_queue_param_t qparam;
>             >       int ret;
>             > -     uint8_t src_mac[ODPH_ETHADDR_LEN];
>             > +     uint8_t src_mac[ODP_MAC_ADDR_MAX_LENGTH];
>
>             I think a helper definition should be used here. I'd not
>         include
>             protocol definitions/types into the main ODP API.
>
>         I wanted a design to help the platform decide the maximum size
>         of MAC_ADDR supported. Any approach is fine.
>
>
>
>             > +     size_t mac_addr_size;
>             >       char src_mac_str[MAX_STRING];
>             >
>             >       /*
>             > @@ -587,8 +588,12 @@ void initialize_intf(char *intf)
>             >       /* Read the source MAC address for this interface */
>             >  #if USE_MAC_ADDR_HACK
>             >       ret = query_mac_address(intf, src_mac);
>             > +     (void)mac_addr_size;
>             >  #else
>             > -     ret = odp_pktio_get_mac_addr(pktio, src_mac);
>             > +     ret = odp_pktio_get_mac_addr(pktio, src_mac,
>         &mac_addr_size);
>             > +     if (mac_addr_size != ODPH_ETHADDR_LEN) {
>             > +             ODP_ABORT("Ethernet mac address length not
>             supported");
>             > +     }
>             >  #endif
>             >       if (ret) {
>             >               ODP_ERR("Error: failed during MAC address
>         get for
>             %s\n",
>             > intf);
>             > diff --git
>         a/platform/linux-generic/include/api/odp_packet_io.h
>             > b/platform/linux-generic/include/api/odp_packet_io.h
>             > index 29fd105..2086316 100644
>             > --- a/platform/linux-generic/include/api/odp_packet_io.h
>             > +++ b/platform/linux-generic/include/api/odp_packet_io.h
>             > @@ -125,6 +125,23 @@ void
>         odp_pktio_set_input(odp_packet_t pkt,
>             > odp_pktio_t id);
>             >   */
>             >  odp_pktio_t odp_pktio_get_input(odp_packet_t pkt);
>             >
>             > +/**
>             > + * Defines the maximum length of mac address supported
>         by this
>             platform
>             > + */
>             > +#define ODP_MAC_ADDR_MAX_LENGTH      ETH_ALEN
>             > +
>             > +/**
>             > + * Get mac address of the interface
>             > + *
>             > + * @param id         ODP packet IO handle
>             > + * @param mac_addr   Storage for Mac address of the
>         packet IO
>             interface
>             > + *                   Storage provided by the caller
>         should be equal
>             > + *                   to ODP_MAC_ADDR_MAX_LENGTH (filled by
>             function)
>
>             "filled by function" ==> output parameter
>
>             > + * @param addr_size  Size of the Mac address (filled by
>         function)
>
>             I think it would be more logical if this is input
>         parameter (==
>             sizeof(mac_addr)) and used for error checking. Function could
>             return the number of bytes copied (6 or 8) on success (and
>         0 on
>             failure). User should know beforehand how large MAC address to
>             expect, right?
>
>         I believe having the maximum MAC_ADDR length being defined by
>         the platform makes the application agnostic across different
>         platform implementations and different types of odp_pktio_t
>         instances.
>         Having the size being returned as a parameter seemed to be
>         more inline with current ODP API design.
>
>
>     Can mac addr be different size? I saw only 6 bytes macs. Not sure
>     if it can be different size. And if it can not be than we don't
>     need ODP_MAC_ADDR_MAX_LENGTH.
>
>     Maxim.
>
>             > + * @return  0 on success or -1 on error
>             > +**/
>             > +int odp_pktio_get_mac_addr(odp_pktio_t id, unsigned
>         char *mac_addr,
>             > +                        size_t *addr_size);
>
>             To be inline with other accessor functions "get" should be
>             dropped. What if an interface is configured to accept
>         multiple mac
>             addresses? Is this the default address (every interface should
>             have at least one mac address). How other MACs are
>         inquired? Or is
>             it part of classification then.
>
>         This API would return the default MAC addr of the instance.
>         Returning multiple mac addr which was assigned to a specific
>         interface could be done by classification.
>
>         Regards,
>         Bala
>
>
>
>             -Petri
>
>
>
>
>         _______________________________________________
>         lng-odp mailing list
>         lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>         http://lists.linaro.org/mailman/listinfo/lng-odp
>
>
>
>     _______________________________________________
>     lng-odp mailing list
>     lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>     http://lists.linaro.org/mailman/listinfo/lng-odp
>
>
Balasubramanian Manoharan Oct. 10, 2014, 7 a.m. UTC | #8
Hi,

* I will change the ODP_MAX_MACADDR_SIZE as 8. where should this macro be
defined is it okay to have it in the current odp_packet_io.h header file.
* I will change the name of the api from odp_pktio_get_mac_addr() to
odp_pktio_mac_addr()
* I will incorporate anders comments also.

Any other changes required for this patch?

Regards,
Bala

On 9 October 2014 21:12, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:

> On 10/09/2014 02:24 PM, Ola Liljedahl wrote:
>
>> Some interface types use 64-bit MAC addresses (e.g. Firewire).
>>
>> I think the ODP API should specify a recommended buffer size (e.g.
>> #define ODP_MACADDR_SIZE 8) and then return the actual length of the return
>> MAC address.
>> The application passes a buffer and a buffer size (this could be 6 if the
>> application is sure that the interface uses a MAC48 address). If the buffer
>> size is too small for the actual MAC address, an error is returned (e.g.
>> -1).
>>
>> -- Ola
>>
>>
> ETH_ALEN is 6. So looks like patch needed to be update.
>
> Maxim.
>
>
>
>> On 8 October 2014 19:08, Maxim Uvarov <maxim.uvarov@linaro.org <mailto:
>> maxim.uvarov@linaro.org>> wrote:
>>
>>     On 10/07/2014 11:47 AM, Bala Manoharan wrote:
>>
>>
>>
>>         On 7 October 2014 12:43, Savolainen, Petri (NSN - FI/Espoo)
>>         <petri.savolainen@nsn.com <mailto:petri.savolainen@nsn.com>
>>         <mailto:petri.savolainen@nsn.com
>>         <mailto:petri.savolainen@nsn.com>>> wrote:
>>
>>
>>
>>             > -----Original Message-----
>>             > From: lng-odp-bounces@lists.linaro.org
>>         <mailto:lng-odp-bounces@lists.linaro.org>
>>             <mailto:lng-odp-bounces@lists.linaro.org
>>         <mailto:lng-odp-bounces@lists.linaro.org>> [mailto:lng-odp-
>>         <mailto:lng-odp->
>>             <mailto:lng-odp- <mailto:lng-odp->>
>>             > bounces@lists.linaro.org
>>         <mailto:bounces@lists.linaro.org>
>>         <mailto:bounces@lists.linaro.org
>>         <mailto:bounces@lists.linaro.org>>] On
>>             Behalf Of ext Balasubramanian Manoharan
>>             > Sent: Monday, October 06, 2014 7:16 PM
>>             > To: lng-odp@lists.linaro.org
>>         <mailto:lng-odp@lists.linaro.org>
>>         <mailto:lng-odp@lists.linaro.org
>>         <mailto:lng-odp@lists.linaro.org>>
>>             > Subject: [lng-odp] [ODP/PATCH v6] API support for
>>         querying mac
>>             address
>>             >
>>             > This patch contains API support for querying mac address
>>         using
>>             odp_pktio_t
>>             > handle
>>             > This patch incorporates the latest ODP_ERR and ODP_ABORT
>>         changes
>>             done in
>>             > linux-generic repo
>>             >
>>             > Signed-off-by: Balasubramanian Manoharan
>>             <bala.manoharan@linaro.org
>>         <mailto:bala.manoharan@linaro.org>
>>         <mailto:bala.manoharan@linaro.org
>>
>>         <mailto:bala.manoharan@linaro.org>>>
>>             > ---
>>             >  example/ipsec/odp_ipsec.c   |  9 ++++++--
>>             > platform/linux-generic/include/api/odp_packet_io.h | 17
>>             +++++++++++++++
>>             >  platform/linux-generic/odp_packet_io.c    | 24
>>             > ++++++++++++++++++++++
>>             >  platform/linux-generic/odp_packet_socket.c    | 16
>>         ++++++++++-----
>>             >  4 files changed, 59 insertions(+), 7 deletions(-)
>>             >
>>             > diff --git a/example/ipsec/odp_ipsec.c
>>         b/example/ipsec/odp_ipsec.c
>>             > index ec6c87a..9a46a0c 100644
>>             > --- a/example/ipsec/odp_ipsec.c
>>             > +++ b/example/ipsec/odp_ipsec.c
>>             > @@ -549,7 +549,8 @@ void initialize_intf(char *intf)
>>             >       char inq_name[ODP_QUEUE_NAME_LEN];
>>             >       odp_queue_param_t qparam;
>>             >       int ret;
>>             > -     uint8_t src_mac[ODPH_ETHADDR_LEN];
>>             > +     uint8_t src_mac[ODP_MAC_ADDR_MAX_LENGTH];
>>
>>             I think a helper definition should be used here. I'd not
>>         include
>>             protocol definitions/types into the main ODP API.
>>
>>         I wanted a design to help the platform decide the maximum size
>>         of MAC_ADDR supported. Any approach is fine.
>>
>>
>>
>>             > +     size_t mac_addr_size;
>>             >       char src_mac_str[MAX_STRING];
>>             >
>>             >       /*
>>             > @@ -587,8 +588,12 @@ void initialize_intf(char *intf)
>>             >       /* Read the source MAC address for this interface */
>>             >  #if USE_MAC_ADDR_HACK
>>             >       ret = query_mac_address(intf, src_mac);
>>             > +     (void)mac_addr_size;
>>             >  #else
>>             > -     ret = odp_pktio_get_mac_addr(pktio, src_mac);
>>             > +     ret = odp_pktio_get_mac_addr(pktio, src_mac,
>>         &mac_addr_size);
>>             > +     if (mac_addr_size != ODPH_ETHADDR_LEN) {
>>             > +             ODP_ABORT("Ethernet mac address length not
>>             supported");
>>             > +     }
>>             >  #endif
>>             >       if (ret) {
>>             >               ODP_ERR("Error: failed during MAC address
>>         get for
>>             %s\n",
>>             > intf);
>>             > diff --git
>>         a/platform/linux-generic/include/api/odp_packet_io.h
>>             > b/platform/linux-generic/include/api/odp_packet_io.h
>>             > index 29fd105..2086316 100644
>>             > --- a/platform/linux-generic/include/api/odp_packet_io.h
>>             > +++ b/platform/linux-generic/include/api/odp_packet_io.h
>>             > @@ -125,6 +125,23 @@ void
>>         odp_pktio_set_input(odp_packet_t pkt,
>>             > odp_pktio_t id);
>>             >   */
>>             >  odp_pktio_t odp_pktio_get_input(odp_packet_t pkt);
>>             >
>>             > +/**
>>             > + * Defines the maximum length of mac address supported
>>         by this
>>             platform
>>             > + */
>>             > +#define ODP_MAC_ADDR_MAX_LENGTH      ETH_ALEN
>>             > +
>>             > +/**
>>             > + * Get mac address of the interface
>>             > + *
>>             > + * @param id         ODP packet IO handle
>>             > + * @param mac_addr   Storage for Mac address of the
>>         packet IO
>>             interface
>>             > + *                   Storage provided by the caller
>>         should be equal
>>             > + *                   to ODP_MAC_ADDR_MAX_LENGTH (filled by
>>             function)
>>
>>             "filled by function" ==> output parameter
>>
>>             > + * @param addr_size  Size of the Mac address (filled by
>>         function)
>>
>>             I think it would be more logical if this is input
>>         parameter (==
>>             sizeof(mac_addr)) and used for error checking. Function could
>>             return the number of bytes copied (6 or 8) on success (and
>>         0 on
>>             failure). User should know beforehand how large MAC address to
>>             expect, right?
>>
>>         I believe having the maximum MAC_ADDR length being defined by
>>         the platform makes the application agnostic across different
>>         platform implementations and different types of odp_pktio_t
>>         instances.
>>         Having the size being returned as a parameter seemed to be
>>         more inline with current ODP API design.
>>
>>
>>     Can mac addr be different size? I saw only 6 bytes macs. Not sure
>>     if it can be different size. And if it can not be than we don't
>>     need ODP_MAC_ADDR_MAX_LENGTH.
>>
>>     Maxim.
>>
>>             > + * @return  0 on success or -1 on error
>>             > +**/
>>             > +int odp_pktio_get_mac_addr(odp_pktio_t id, unsigned
>>         char *mac_addr,
>>             > +                        size_t *addr_size);
>>
>>             To be inline with other accessor functions "get" should be
>>             dropped. What if an interface is configured to accept
>>         multiple mac
>>             addresses? Is this the default address (every interface should
>>             have at least one mac address). How other MACs are
>>         inquired? Or is
>>             it part of classification then.
>>
>>         This API would return the default MAC addr of the instance.
>>         Returning multiple mac addr which was assigned to a specific
>>         interface could be done by classification.
>>
>>         Regards,
>>         Bala
>>
>>
>>
>>             -Petri
>>
>>
>>
>>
>>         _______________________________________________
>>         lng-odp mailing list
>>         lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>>         http://lists.linaro.org/mailman/listinfo/lng-odp
>>
>>
>>
>>     _______________________________________________
>>     lng-odp mailing list
>>     lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>>     http://lists.linaro.org/mailman/listinfo/lng-odp
>>
>>
>>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
Savolainen, Petri (NSN - FI/Espoo) Oct. 10, 2014, 9:11 a.m. UTC | #9
I think ODP_MAX_MACADDR_SIZE is not needed in API, if user gives sizeof(mac_addr) and func returns size copied.  It can be added in eth helper file though (e.g. ODPH_ETH_MACADDR_SIZE_MAX).

It’s again a protocol definition that I’d rather leave out when possible.

-Petri


From: lng-odp-bounces@lists.linaro.org [mailto:lng-odp-bounces@lists.linaro.org] On Behalf Of ext Bala Manoharan

Sent: Friday, October 10, 2014 10:00 AM
To: Maxim Uvarov
Cc: lng-odp@lists.linaro.org
Subject: Re: [lng-odp] [ODP/PATCH v6] API support for querying mac address

Hi,

* I will change the ODP_MAX_MACADDR_SIZE as 8. where should this macro be defined is it okay to have it in the current odp_packet_io.h header file.
* I will change the name of the api from odp_pktio_get_mac_addr() to odp_pktio_mac_addr()
* I will incorporate anders comments also.
Any other changes required for this patch?

Regards,
Bala

On 9 October 2014 21:12, Maxim Uvarov <maxim.uvarov@linaro.org<mailto:maxim.uvarov@linaro.org>> wrote:
On 10/09/2014 02:24 PM, Ola Liljedahl wrote:
Some interface types use 64-bit MAC addresses (e.g. Firewire).

I think the ODP API should specify a recommended buffer size (e.g. #define ODP_MACADDR_SIZE 8) and then return the actual length of the return MAC address.
The application passes a buffer and a buffer size (this could be 6 if the application is sure that the interface uses a MAC48 address). If the buffer size is too small for the actual MAC address, an error is returned (e.g. -1).

-- Ola

ETH_ALEN is 6. So looks like patch needed to be update.

Maxim.


On 8 October 2014 19:08, Maxim Uvarov <maxim.uvarov@linaro.org<mailto:maxim.uvarov@linaro.org> <mailto:maxim.uvarov@linaro.org<mailto:maxim.uvarov@linaro.org>>> wrote:

    On 10/07/2014 11:47 AM, Bala Manoharan wrote:



        On 7 October 2014 12:43, Savolainen, Petri (NSN - FI/Espoo)
        <petri.savolainen@nsn.com<mailto:petri.savolainen@nsn.com> <mailto:petri.savolainen@nsn.com<mailto:petri.savolainen@nsn.com>>
        <mailto:petri.savolainen@nsn.com<mailto:petri.savolainen@nsn.com>
        <mailto:petri.savolainen@nsn.com<mailto:petri.savolainen@nsn.com>>>> wrote:



            > -----Original Message-----

            > From: lng-odp-bounces@lists.linaro.org<mailto:lng-odp-bounces@lists.linaro.org>

        <mailto:lng-odp-bounces@lists.linaro.org<mailto:lng-odp-bounces@lists.linaro.org>>
            <mailto:lng-odp-bounces@lists.linaro.org<mailto:lng-odp-bounces@lists.linaro.org>
        <mailto:lng-odp-bounces@lists.linaro.org<mailto:lng-odp-bounces@lists.linaro.org>>> [mailto:lng-odp-<mailto:lng-odp->
        <mailto:lng-odp-<mailto:lng-odp->>
            <mailto:lng-odp-<mailto:lng-odp-> <mailto:lng-odp-<mailto:lng-odp->>>
            > bounces@lists.linaro.org<mailto:bounces@lists.linaro.org>

        <mailto:bounces@lists.linaro.org<mailto:bounces@lists.linaro.org>>
        <mailto:bounces@lists.linaro.org<mailto:bounces@lists.linaro.org>
        <mailto:bounces@lists.linaro.org<mailto:bounces@lists.linaro.org>>>] On
            Behalf Of ext Balasubramanian Manoharan
            > Sent: Monday, October 06, 2014 7:16 PM

            > To: lng-odp@lists.linaro.org<mailto:lng-odp@lists.linaro.org>

        <mailto:lng-odp@lists.linaro.org<mailto:lng-odp@lists.linaro.org>>
        <mailto:lng-odp@lists.linaro.org<mailto:lng-odp@lists.linaro.org>
        <mailto:lng-odp@lists.linaro.org<mailto:lng-odp@lists.linaro.org>>>
            > Subject: [lng-odp] [ODP/PATCH v6] API support for

        querying mac
            address
            >

            > This patch contains API support for querying mac address

        using
            odp_pktio_t
            > handle

            > This patch incorporates the latest ODP_ERR and ODP_ABORT

        changes
            done in
            > linux-generic repo

            >

            > Signed-off-by: Balasubramanian Manoharan

            <bala.manoharan@linaro.org<mailto:bala.manoharan@linaro.org>
        <mailto:bala.manoharan@linaro.org<mailto:bala.manoharan@linaro.org>>
        <mailto:bala.manoharan@linaro.org<mailto:bala.manoharan@linaro.org>

        <mailto:bala.manoharan@linaro.org<mailto:bala.manoharan@linaro.org>>>>
            > ---

            >  example/ipsec/odp_ipsec.c   |  9 ++++++--

            > platform/linux-generic/include/api/odp_packet_io.h | 17

            +++++++++++++++
            >  platform/linux-generic/odp_packet_io.c    | 24

            > ++++++++++++++++++++++

            >  platform/linux-generic/odp_packet_socket.c    | 16

        ++++++++++-----
            >  4 files changed, 59 insertions(+), 7 deletions(-)

            >

            > diff --git a/example/ipsec/odp_ipsec.c

        b/example/ipsec/odp_ipsec.c
            > index ec6c87a..9a46a0c 100644

            > --- a/example/ipsec/odp_ipsec.c

            > +++ b/example/ipsec/odp_ipsec.c

            > @@ -549,7 +549,8 @@ void initialize_intf(char *intf)

            >       char inq_name[ODP_QUEUE_NAME_LEN];

            >       odp_queue_param_t qparam;

            >       int ret;

            > -     uint8_t src_mac[ODPH_ETHADDR_LEN];

            > +     uint8_t src_mac[ODP_MAC_ADDR_MAX_LENGTH];


            I think a helper definition should be used here. I'd not
        include
            protocol definitions/types into the main ODP API.

        I wanted a design to help the platform decide the maximum size
        of MAC_ADDR supported. Any approach is fine.



            > +     size_t mac_addr_size;

            >       char src_mac_str[MAX_STRING];

            >

            >       /*

            > @@ -587,8 +588,12 @@ void initialize_intf(char *intf)

            >       /* Read the source MAC address for this interface */

            >  #if USE_MAC_ADDR_HACK

            >       ret = query_mac_address(intf, src_mac);

            > +     (void)mac_addr_size;

            >  #else

            > -     ret = odp_pktio_get_mac_addr(pktio, src_mac);

            > +     ret = odp_pktio_get_mac_addr(pktio, src_mac,

        &mac_addr_size);
            > +     if (mac_addr_size != ODPH_ETHADDR_LEN) {

            > +             ODP_ABORT("Ethernet mac address length not

            supported");
            > +     }

            >  #endif

            >       if (ret) {

            >               ODP_ERR("Error: failed during MAC address

        get for
            %s\n",
            > intf);

            > diff --git

        a/platform/linux-generic/include/api/odp_packet_io.h
            > b/platform/linux-generic/include/api/odp_packet_io.h

            > index 29fd105..2086316 100644

            > --- a/platform/linux-generic/include/api/odp_packet_io.h

            > +++ b/platform/linux-generic/include/api/odp_packet_io.h

            > @@ -125,6 +125,23 @@ void

        odp_pktio_set_input(odp_packet_t pkt,
            > odp_pktio_t id);

            >   */

            >  odp_pktio_t odp_pktio_get_input(odp_packet_t pkt);

            >

            > +/**

            > + * Defines the maximum length of mac address supported

        by this
            platform
            > + */

            > +#define ODP_MAC_ADDR_MAX_LENGTH      ETH_ALEN

            > +

            > +/**

            > + * Get mac address of the interface

            > + *

            > + * @param id         ODP packet IO handle

            > + * @param mac_addr   Storage for Mac address of the

        packet IO
            interface
            > + *                   Storage provided by the caller

        should be equal
            > + *                   to ODP_MAC_ADDR_MAX_LENGTH (filled by

            function)

            "filled by function" ==> output parameter

            > + * @param addr_size  Size of the Mac address (filled by

        function)

            I think it would be more logical if this is input
        parameter (==
            sizeof(mac_addr)) and used for error checking. Function could
            return the number of bytes copied (6 or 8) on success (and
        0 on
            failure). User should know beforehand how large MAC address to
            expect, right?

        I believe having the maximum MAC_ADDR length being defined by
        the platform makes the application agnostic across different
        platform implementations and different types of odp_pktio_t
        instances.
        Having the size being returned as a parameter seemed to be
        more inline with current ODP API design.


    Can mac addr be different size? I saw only 6 bytes macs. Not sure
    if it can be different size. And if it can not be than we don't
    need ODP_MAC_ADDR_MAX_LENGTH.

    Maxim.

            > + * @return  0 on success or -1 on error

            > +**/

            > +int odp_pktio_get_mac_addr(odp_pktio_t id, unsigned

        char *mac_addr,
            > +                        size_t *addr_size);


            To be inline with other accessor functions "get" should be
            dropped. What if an interface is configured to accept
        multiple mac
            addresses? Is this the default address (every interface should
            have at least one mac address). How other MACs are
        inquired? Or is
            it part of classification then.

        This API would return the default MAC addr of the instance.
        Returning multiple mac addr which was assigned to a specific
        interface could be done by classification.

        Regards,
        Bala



            -Petri




        _______________________________________________
        lng-odp mailing list
        lng-odp@lists.linaro.org<mailto:lng-odp@lists.linaro.org> <mailto:lng-odp@lists.linaro.org<mailto:lng-odp@lists.linaro.org>>
        http://lists.linaro.org/mailman/listinfo/lng-odp



    _______________________________________________
    lng-odp mailing list
    lng-odp@lists.linaro.org<mailto:lng-odp@lists.linaro.org> <mailto:lng-odp@lists.linaro.org<mailto:lng-odp@lists.linaro.org>>
    http://lists.linaro.org/mailman/listinfo/lng-odp



_______________________________________________
lng-odp mailing list
lng-odp@lists.linaro.org<mailto:lng-odp@lists.linaro.org>
http://lists.linaro.org/mailman/listinfo/lng-odp
Bill Fischofer Oct. 10, 2014, 2:11 p.m. UTC | #10
I agree.  The only protocols we're dealing with in ODP v1.0  are Ethernet
and for that MACs follow the EUI-48 format so they are always 6 bytes in
length.

Bill

On Fri, Oct 10, 2014 at 4:11 AM, Savolainen, Petri (NSN - FI/Espoo) <
petri.savolainen@nsn.com> wrote:

>  I think ODP_MAX_MACADDR_SIZE is not needed in API, if user gives
> sizeof(mac_addr) and func returns size copied.  It can be added in eth
> helper file though (e.g. ODPH_ETH_MACADDR_SIZE_MAX).
>
>
>
> It’s again a protocol definition that I’d rather leave out when possible.
>
>
>
> -Petri
>
>
>
>
>
> *From:* lng-odp-bounces@lists.linaro.org [mailto:
> lng-odp-bounces@lists.linaro.org] *On Behalf Of *ext Bala Manoharan
> *Sent:* Friday, October 10, 2014 10:00 AM
> *To:* Maxim Uvarov
> *Cc:* lng-odp@lists.linaro.org
> *Subject:* Re: [lng-odp] [ODP/PATCH v6] API support for querying mac
> address
>
>
>
> Hi,
>
>
>
> * I will change the ODP_MAX_MACADDR_SIZE as 8. where should this macro be
> defined is it okay to have it in the current odp_packet_io.h header file.
>
> * I will change the name of the api from odp_pktio_get_mac_addr() to
> odp_pktio_mac_addr()
>
> * I will incorporate anders comments also.
>
> Any other changes required for this patch?
>
> Regards,
>
> Bala
>
>
>
> On 9 October 2014 21:12, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:
>
> On 10/09/2014 02:24 PM, Ola Liljedahl wrote:
>
> Some interface types use 64-bit MAC addresses (e.g. Firewire).
>
> I think the ODP API should specify a recommended buffer size (e.g. #define
> ODP_MACADDR_SIZE 8) and then return the actual length of the return MAC
> address.
> The application passes a buffer and a buffer size (this could be 6 if the
> application is sure that the interface uses a MAC48 address). If the buffer
> size is too small for the actual MAC address, an error is returned (e.g.
> -1).
>
> -- Ola
>
>
> ETH_ALEN is 6. So looks like patch needed to be update.
>
> Maxim.
>
>
> On 8 October 2014 19:08, Maxim Uvarov <maxim.uvarov@linaro.org <mailto:
> maxim.uvarov@linaro.org>> wrote:
>
>     On 10/07/2014 11:47 AM, Bala Manoharan wrote:
>
>
>
>         On 7 October 2014 12:43, Savolainen, Petri (NSN - FI/Espoo)
>         <petri.savolainen@nsn.com <mailto:petri.savolainen@nsn.com>
>         <mailto:petri.savolainen@nsn.com
>         <mailto:petri.savolainen@nsn.com>>> wrote:
>
>
>
>             > -----Original Message-----
>             > From: lng-odp-bounces@lists.linaro.org
>         <mailto:lng-odp-bounces@lists.linaro.org>
>             <mailto:lng-odp-bounces@lists.linaro.org
>         <mailto:lng-odp-bounces@lists.linaro.org>> [mailto:lng-odp-
>         <mailto:lng-odp->
>             <mailto:lng-odp- <mailto:lng-odp->>
>             > bounces@lists.linaro.org
>         <mailto:bounces@lists.linaro.org>
>         <mailto:bounces@lists.linaro.org
>         <mailto:bounces@lists.linaro.org>>] On
>             Behalf Of ext Balasubramanian Manoharan
>             > Sent: Monday, October 06, 2014 7:16 PM
>             > To: lng-odp@lists.linaro.org
>         <mailto:lng-odp@lists.linaro.org>
>         <mailto:lng-odp@lists.linaro.org
>         <mailto:lng-odp@lists.linaro.org>>
>             > Subject: [lng-odp] [ODP/PATCH v6] API support for
>         querying mac
>             address
>             >
>             > This patch contains API support for querying mac address
>         using
>             odp_pktio_t
>             > handle
>             > This patch incorporates the latest ODP_ERR and ODP_ABORT
>         changes
>             done in
>             > linux-generic repo
>             >
>             > Signed-off-by: Balasubramanian Manoharan
>             <bala.manoharan@linaro.org
>         <mailto:bala.manoharan@linaro.org>
>         <mailto:bala.manoharan@linaro.org
>
>
>         <mailto:bala.manoharan@linaro.org>>>
>             > ---
>             >  example/ipsec/odp_ipsec.c   |  9 ++++++--
>             > platform/linux-generic/include/api/odp_packet_io.h | 17
>             +++++++++++++++
>             >  platform/linux-generic/odp_packet_io.c    | 24
>             > ++++++++++++++++++++++
>             >  platform/linux-generic/odp_packet_socket.c    | 16
>         ++++++++++-----
>             >  4 files changed, 59 insertions(+), 7 deletions(-)
>             >
>             > diff --git a/example/ipsec/odp_ipsec.c
>         b/example/ipsec/odp_ipsec.c
>             > index ec6c87a..9a46a0c 100644
>             > --- a/example/ipsec/odp_ipsec.c
>             > +++ b/example/ipsec/odp_ipsec.c
>             > @@ -549,7 +549,8 @@ void initialize_intf(char *intf)
>             >       char inq_name[ODP_QUEUE_NAME_LEN];
>             >       odp_queue_param_t qparam;
>             >       int ret;
>             > -     uint8_t src_mac[ODPH_ETHADDR_LEN];
>             > +     uint8_t src_mac[ODP_MAC_ADDR_MAX_LENGTH];
>
>             I think a helper definition should be used here. I'd not
>         include
>             protocol definitions/types into the main ODP API.
>
>         I wanted a design to help the platform decide the maximum size
>         of MAC_ADDR supported. Any approach is fine.
>
>
>
>             > +     size_t mac_addr_size;
>             >       char src_mac_str[MAX_STRING];
>             >
>             >       /*
>             > @@ -587,8 +588,12 @@ void initialize_intf(char *intf)
>             >       /* Read the source MAC address for this interface */
>             >  #if USE_MAC_ADDR_HACK
>             >       ret = query_mac_address(intf, src_mac);
>             > +     (void)mac_addr_size;
>             >  #else
>             > -     ret = odp_pktio_get_mac_addr(pktio, src_mac);
>             > +     ret = odp_pktio_get_mac_addr(pktio, src_mac,
>         &mac_addr_size);
>             > +     if (mac_addr_size != ODPH_ETHADDR_LEN) {
>             > +             ODP_ABORT("Ethernet mac address length not
>             supported");
>             > +     }
>             >  #endif
>             >       if (ret) {
>             >               ODP_ERR("Error: failed during MAC address
>         get for
>             %s\n",
>             > intf);
>             > diff --git
>         a/platform/linux-generic/include/api/odp_packet_io.h
>             > b/platform/linux-generic/include/api/odp_packet_io.h
>             > index 29fd105..2086316 100644
>             > --- a/platform/linux-generic/include/api/odp_packet_io.h
>             > +++ b/platform/linux-generic/include/api/odp_packet_io.h
>             > @@ -125,6 +125,23 @@ void
>         odp_pktio_set_input(odp_packet_t pkt,
>             > odp_pktio_t id);
>             >   */
>             >  odp_pktio_t odp_pktio_get_input(odp_packet_t pkt);
>             >
>             > +/**
>             > + * Defines the maximum length of mac address supported
>         by this
>             platform
>             > + */
>             > +#define ODP_MAC_ADDR_MAX_LENGTH      ETH_ALEN
>             > +
>             > +/**
>             > + * Get mac address of the interface
>             > + *
>             > + * @param id         ODP packet IO handle
>             > + * @param mac_addr   Storage for Mac address of the
>         packet IO
>             interface
>             > + *                   Storage provided by the caller
>         should be equal
>             > + *                   to ODP_MAC_ADDR_MAX_LENGTH (filled by
>             function)
>
>             "filled by function" ==> output parameter
>
>             > + * @param addr_size  Size of the Mac address (filled by
>         function)
>
>             I think it would be more logical if this is input
>         parameter (==
>             sizeof(mac_addr)) and used for error checking. Function could
>             return the number of bytes copied (6 or 8) on success (and
>         0 on
>             failure). User should know beforehand how large MAC address to
>             expect, right?
>
>         I believe having the maximum MAC_ADDR length being defined by
>         the platform makes the application agnostic across different
>         platform implementations and different types of odp_pktio_t
>         instances.
>         Having the size being returned as a parameter seemed to be
>         more inline with current ODP API design.
>
>
>     Can mac addr be different size? I saw only 6 bytes macs. Not sure
>     if it can be different size. And if it can not be than we don't
>     need ODP_MAC_ADDR_MAX_LENGTH.
>
>     Maxim.
>
>             > + * @return  0 on success or -1 on error
>             > +**/
>             > +int odp_pktio_get_mac_addr(odp_pktio_t id, unsigned
>         char *mac_addr,
>             > +                        size_t *addr_size);
>
>             To be inline with other accessor functions "get" should be
>             dropped. What if an interface is configured to accept
>         multiple mac
>             addresses? Is this the default address (every interface should
>             have at least one mac address). How other MACs are
>         inquired? Or is
>             it part of classification then.
>
>         This API would return the default MAC addr of the instance.
>         Returning multiple mac addr which was assigned to a specific
>         interface could be done by classification.
>
>         Regards,
>         Bala
>
>
>
>             -Petri
>
>
>
>
>         _______________________________________________
>         lng-odp mailing list
>
>         lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>         http://lists.linaro.org/mailman/listinfo/lng-odp
>
>
>
>     _______________________________________________
>     lng-odp mailing list
>     lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>     http://lists.linaro.org/mailman/listinfo/lng-odp
>
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
>
Balasubramanian Manoharan Oct. 13, 2014, 12:21 p.m. UTC | #11
Hi,

ODP_MAX_MACADDR_SIZE was needed since we wanted this API to be compliant
for both 6 and 8 byte MAC address.
Since we are having odp_pktio_t as abstract application cannot assume the
mac address to be the size of Ethernet.
That was the whole point behind having an MAX size being defined by the
platform and returning the size as an output parameter.

My proposal is to keep the mechanism to support any size of MAC address but
only implement the same for Ethernet in the ODP v1.0 so that there is no
change in the API signature when updating for v2.0

Regards,
Bala


On 10 October 2014 19:41, Bill Fischofer <bill.fischofer@linaro.org> wrote:

> I agree.  The only protocols we're dealing with in ODP v1.0  are Ethernet
> and for that MACs follow the EUI-48 format so they are always 6 bytes in
> length.
>
> Bill
>
> On Fri, Oct 10, 2014 at 4:11 AM, Savolainen, Petri (NSN - FI/Espoo) <
> petri.savolainen@nsn.com> wrote:
>
>>  I think ODP_MAX_MACADDR_SIZE is not needed in API, if user gives
>> sizeof(mac_addr) and func returns size copied.  It can be added in eth
>> helper file though (e.g. ODPH_ETH_MACADDR_SIZE_MAX).
>>
>>
>>
>> It’s again a protocol definition that I’d rather leave out when possible.
>>
>>
>>
>> -Petri
>>
>>
>>
>>
>>
>> *From:* lng-odp-bounces@lists.linaro.org [mailto:
>> lng-odp-bounces@lists.linaro.org] *On Behalf Of *ext Bala Manoharan
>> *Sent:* Friday, October 10, 2014 10:00 AM
>> *To:* Maxim Uvarov
>> *Cc:* lng-odp@lists.linaro.org
>> *Subject:* Re: [lng-odp] [ODP/PATCH v6] API support for querying mac
>> address
>>
>>
>>
>> Hi,
>>
>>
>>
>> * I will change the ODP_MAX_MACADDR_SIZE as 8. where should this macro be
>> defined is it okay to have it in the current odp_packet_io.h header file.
>>
>> * I will change the name of the api from odp_pktio_get_mac_addr() to
>> odp_pktio_mac_addr()
>>
>> * I will incorporate anders comments also.
>>
>> Any other changes required for this patch?
>>
>> Regards,
>>
>> Bala
>>
>>
>>
>> On 9 October 2014 21:12, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:
>>
>> On 10/09/2014 02:24 PM, Ola Liljedahl wrote:
>>
>> Some interface types use 64-bit MAC addresses (e.g. Firewire).
>>
>> I think the ODP API should specify a recommended buffer size (e.g.
>> #define ODP_MACADDR_SIZE 8) and then return the actual length of the return
>> MAC address.
>> The application passes a buffer and a buffer size (this could be 6 if the
>> application is sure that the interface uses a MAC48 address). If the buffer
>> size is too small for the actual MAC address, an error is returned (e.g.
>> -1).
>>
>> -- Ola
>>
>>
>> ETH_ALEN is 6. So looks like patch needed to be update.
>>
>> Maxim.
>>
>>
>> On 8 October 2014 19:08, Maxim Uvarov <maxim.uvarov@linaro.org <mailto:
>> maxim.uvarov@linaro.org>> wrote:
>>
>>     On 10/07/2014 11:47 AM, Bala Manoharan wrote:
>>
>>
>>
>>         On 7 October 2014 12:43, Savolainen, Petri (NSN - FI/Espoo)
>>         <petri.savolainen@nsn.com <mailto:petri.savolainen@nsn.com>
>>         <mailto:petri.savolainen@nsn.com
>>         <mailto:petri.savolainen@nsn.com>>> wrote:
>>
>>
>>
>>             > -----Original Message-----
>>             > From: lng-odp-bounces@lists.linaro.org
>>         <mailto:lng-odp-bounces@lists.linaro.org>
>>             <mailto:lng-odp-bounces@lists.linaro.org
>>         <mailto:lng-odp-bounces@lists.linaro.org>> [mailto:lng-odp-
>>         <mailto:lng-odp->
>>             <mailto:lng-odp- <mailto:lng-odp->>
>>             > bounces@lists.linaro.org
>>         <mailto:bounces@lists.linaro.org>
>>         <mailto:bounces@lists.linaro.org
>>         <mailto:bounces@lists.linaro.org>>] On
>>             Behalf Of ext Balasubramanian Manoharan
>>             > Sent: Monday, October 06, 2014 7:16 PM
>>             > To: lng-odp@lists.linaro.org
>>         <mailto:lng-odp@lists.linaro.org>
>>         <mailto:lng-odp@lists.linaro.org
>>         <mailto:lng-odp@lists.linaro.org>>
>>             > Subject: [lng-odp] [ODP/PATCH v6] API support for
>>         querying mac
>>             address
>>             >
>>             > This patch contains API support for querying mac address
>>         using
>>             odp_pktio_t
>>             > handle
>>             > This patch incorporates the latest ODP_ERR and ODP_ABORT
>>         changes
>>             done in
>>             > linux-generic repo
>>             >
>>             > Signed-off-by: Balasubramanian Manoharan
>>             <bala.manoharan@linaro.org
>>         <mailto:bala.manoharan@linaro.org>
>>         <mailto:bala.manoharan@linaro.org
>>
>>
>>         <mailto:bala.manoharan@linaro.org>>>
>>             > ---
>>             >  example/ipsec/odp_ipsec.c   |  9 ++++++--
>>             > platform/linux-generic/include/api/odp_packet_io.h | 17
>>             +++++++++++++++
>>             >  platform/linux-generic/odp_packet_io.c    | 24
>>             > ++++++++++++++++++++++
>>             >  platform/linux-generic/odp_packet_socket.c    | 16
>>         ++++++++++-----
>>             >  4 files changed, 59 insertions(+), 7 deletions(-)
>>             >
>>             > diff --git a/example/ipsec/odp_ipsec.c
>>         b/example/ipsec/odp_ipsec.c
>>             > index ec6c87a..9a46a0c 100644
>>             > --- a/example/ipsec/odp_ipsec.c
>>             > +++ b/example/ipsec/odp_ipsec.c
>>             > @@ -549,7 +549,8 @@ void initialize_intf(char *intf)
>>             >       char inq_name[ODP_QUEUE_NAME_LEN];
>>             >       odp_queue_param_t qparam;
>>             >       int ret;
>>             > -     uint8_t src_mac[ODPH_ETHADDR_LEN];
>>             > +     uint8_t src_mac[ODP_MAC_ADDR_MAX_LENGTH];
>>
>>             I think a helper definition should be used here. I'd not
>>         include
>>             protocol definitions/types into the main ODP API.
>>
>>         I wanted a design to help the platform decide the maximum size
>>         of MAC_ADDR supported. Any approach is fine.
>>
>>
>>
>>             > +     size_t mac_addr_size;
>>             >       char src_mac_str[MAX_STRING];
>>             >
>>             >       /*
>>             > @@ -587,8 +588,12 @@ void initialize_intf(char *intf)
>>             >       /* Read the source MAC address for this interface */
>>             >  #if USE_MAC_ADDR_HACK
>>             >       ret = query_mac_address(intf, src_mac);
>>             > +     (void)mac_addr_size;
>>             >  #else
>>             > -     ret = odp_pktio_get_mac_addr(pktio, src_mac);
>>             > +     ret = odp_pktio_get_mac_addr(pktio, src_mac,
>>         &mac_addr_size);
>>             > +     if (mac_addr_size != ODPH_ETHADDR_LEN) {
>>             > +             ODP_ABORT("Ethernet mac address length not
>>             supported");
>>             > +     }
>>             >  #endif
>>             >       if (ret) {
>>             >               ODP_ERR("Error: failed during MAC address
>>         get for
>>             %s\n",
>>             > intf);
>>             > diff --git
>>         a/platform/linux-generic/include/api/odp_packet_io.h
>>             > b/platform/linux-generic/include/api/odp_packet_io.h
>>             > index 29fd105..2086316 100644
>>             > --- a/platform/linux-generic/include/api/odp_packet_io.h
>>             > +++ b/platform/linux-generic/include/api/odp_packet_io.h
>>             > @@ -125,6 +125,23 @@ void
>>         odp_pktio_set_input(odp_packet_t pkt,
>>             > odp_pktio_t id);
>>             >   */
>>             >  odp_pktio_t odp_pktio_get_input(odp_packet_t pkt);
>>             >
>>             > +/**
>>             > + * Defines the maximum length of mac address supported
>>         by this
>>             platform
>>             > + */
>>             > +#define ODP_MAC_ADDR_MAX_LENGTH      ETH_ALEN
>>             > +
>>             > +/**
>>             > + * Get mac address of the interface
>>             > + *
>>             > + * @param id         ODP packet IO handle
>>             > + * @param mac_addr   Storage for Mac address of the
>>         packet IO
>>             interface
>>             > + *                   Storage provided by the caller
>>         should be equal
>>             > + *                   to ODP_MAC_ADDR_MAX_LENGTH (filled by
>>             function)
>>
>>             "filled by function" ==> output parameter
>>
>>             > + * @param addr_size  Size of the Mac address (filled by
>>         function)
>>
>>             I think it would be more logical if this is input
>>         parameter (==
>>             sizeof(mac_addr)) and used for error checking. Function could
>>             return the number of bytes copied (6 or 8) on success (and
>>         0 on
>>             failure). User should know beforehand how large MAC address to
>>             expect, right?
>>
>>         I believe having the maximum MAC_ADDR length being defined by
>>         the platform makes the application agnostic across different
>>         platform implementations and different types of odp_pktio_t
>>         instances.
>>         Having the size being returned as a parameter seemed to be
>>         more inline with current ODP API design.
>>
>>
>>     Can mac addr be different size? I saw only 6 bytes macs. Not sure
>>     if it can be different size. And if it can not be than we don't
>>     need ODP_MAC_ADDR_MAX_LENGTH.
>>
>>     Maxim.
>>
>>             > + * @return  0 on success or -1 on error
>>             > +**/
>>             > +int odp_pktio_get_mac_addr(odp_pktio_t id, unsigned
>>         char *mac_addr,
>>             > +                        size_t *addr_size);
>>
>>             To be inline with other accessor functions "get" should be
>>             dropped. What if an interface is configured to accept
>>         multiple mac
>>             addresses? Is this the default address (every interface should
>>             have at least one mac address). How other MACs are
>>         inquired? Or is
>>             it part of classification then.
>>
>>         This API would return the default MAC addr of the instance.
>>         Returning multiple mac addr which was assigned to a specific
>>         interface could be done by classification.
>>
>>         Regards,
>>         Bala
>>
>>
>>
>>             -Petri
>>
>>
>>
>>
>>         _______________________________________________
>>         lng-odp mailing list
>>
>>         lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>>         http://lists.linaro.org/mailman/listinfo/lng-odp
>>
>>
>>
>>     _______________________________________________
>>     lng-odp mailing list
>>     lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>>     http://lists.linaro.org/mailman/listinfo/lng-odp
>>
>>
>>
>> _______________________________________________
>> lng-odp mailing list
>> lng-odp@lists.linaro.org
>> http://lists.linaro.org/mailman/listinfo/lng-odp
>>
>>
>>
>> _______________________________________________
>> lng-odp mailing list
>> lng-odp@lists.linaro.org
>> http://lists.linaro.org/mailman/listinfo/lng-odp
>>
>>
>
Ciprian Barbu Oct. 14, 2014, 12:31 p.m. UTC | #12
On Mon, Oct 13, 2014 at 3:21 PM, Bala Manoharan
<bala.manoharan@linaro.org> wrote:
> Hi,
>
> ODP_MAX_MACADDR_SIZE was needed since we wanted this API to be compliant for
> both 6 and 8 byte MAC address.
> Since we are having odp_pktio_t as abstract application cannot assume the
> mac address to be the size of Ethernet.
> That was the whole point behind having an MAX size being defined by the
> platform and returning the size as an output parameter.

It doesn't feel right to me to have a platform dependent
MAX_MACADDR_SIZE. Sure it could be the size of the longest MAC address
of the interfaces that exist on the board in question, but you still
have USB ports that could be used to connect a whole range of devices,
firewire like Ola mentioned and who knows what else. To limit
ourselves to Ethernet devices is a safe bet, but can't we do more? I
would suggest something similar to Petri's idea, pass the destination
buffer and it's size and the API to return the number of bytes copied
if that was enough, or the number of bytes necessary otherwise.
Something like snprintf, but not assuming we're copying a readable
string.

>
> My proposal is to keep the mechanism to support any size of MAC address but
> only implement the same for Ethernet in the ODP v1.0 so that there is no
> change in the API signature when updating for v2.0
>
> Regards,
> Bala
>
>
> On 10 October 2014 19:41, Bill Fischofer <bill.fischofer@linaro.org> wrote:
>>
>> I agree.  The only protocols we're dealing with in ODP v1.0  are Ethernet
>> and for that MACs follow the EUI-48 format so they are always 6 bytes in
>> length.
>>
>> Bill
>>
>> On Fri, Oct 10, 2014 at 4:11 AM, Savolainen, Petri (NSN - FI/Espoo)
>> <petri.savolainen@nsn.com> wrote:
>>>
>>> I think ODP_MAX_MACADDR_SIZE is not needed in API, if user gives
>>> sizeof(mac_addr) and func returns size copied.  It can be added in eth
>>> helper file though (e.g. ODPH_ETH_MACADDR_SIZE_MAX).
>>>
>>>
>>>
>>> It’s again a protocol definition that I’d rather leave out when possible.
>>>
>>>
>>>
>>> -Petri
>>>
>>>
>>>
>>>
>>>
>>> From: lng-odp-bounces@lists.linaro.org
>>> [mailto:lng-odp-bounces@lists.linaro.org] On Behalf Of ext Bala Manoharan
>>> Sent: Friday, October 10, 2014 10:00 AM
>>> To: Maxim Uvarov
>>> Cc: lng-odp@lists.linaro.org
>>> Subject: Re: [lng-odp] [ODP/PATCH v6] API support for querying mac
>>> address
>>>
>>>
>>>
>>> Hi,
>>>
>>>
>>>
>>> * I will change the ODP_MAX_MACADDR_SIZE as 8. where should this macro be
>>> defined is it okay to have it in the current odp_packet_io.h header file.
>>>
>>> * I will change the name of the api from odp_pktio_get_mac_addr() to
>>> odp_pktio_mac_addr()
>>>
>>> * I will incorporate anders comments also.
>>>
>>> Any other changes required for this patch?
>>>
>>> Regards,
>>>
>>> Bala
>>>
>>>
>>>
>>> On 9 October 2014 21:12, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:
>>>
>>> On 10/09/2014 02:24 PM, Ola Liljedahl wrote:
>>>
>>> Some interface types use 64-bit MAC addresses (e.g. Firewire).
>>>
>>> I think the ODP API should specify a recommended buffer size (e.g.
>>> #define ODP_MACADDR_SIZE 8) and then return the actual length of the return
>>> MAC address.
>>> The application passes a buffer and a buffer size (this could be 6 if the
>>> application is sure that the interface uses a MAC48 address). If the buffer
>>> size is too small for the actual MAC address, an error is returned (e.g.
>>> -1).
>>>
>>> -- Ola
>>>
>>>
>>> ETH_ALEN is 6. So looks like patch needed to be update.
>>>
>>> Maxim.
>>>
>>>
>>> On 8 October 2014 19:08, Maxim Uvarov <maxim.uvarov@linaro.org
>>> <mailto:maxim.uvarov@linaro.org>> wrote:
>>>
>>>     On 10/07/2014 11:47 AM, Bala Manoharan wrote:
>>>
>>>
>>>
>>>         On 7 October 2014 12:43, Savolainen, Petri (NSN - FI/Espoo)
>>>         <petri.savolainen@nsn.com <mailto:petri.savolainen@nsn.com>
>>>         <mailto:petri.savolainen@nsn.com
>>>         <mailto:petri.savolainen@nsn.com>>> wrote:
>>>
>>>
>>>
>>>             > -----Original Message-----
>>>             > From: lng-odp-bounces@lists.linaro.org
>>>         <mailto:lng-odp-bounces@lists.linaro.org>
>>>             <mailto:lng-odp-bounces@lists.linaro.org
>>>         <mailto:lng-odp-bounces@lists.linaro.org>> [mailto:lng-odp-
>>>         <mailto:lng-odp->
>>>             <mailto:lng-odp- <mailto:lng-odp->>
>>>             > bounces@lists.linaro.org
>>>         <mailto:bounces@lists.linaro.org>
>>>         <mailto:bounces@lists.linaro.org
>>>         <mailto:bounces@lists.linaro.org>>] On
>>>             Behalf Of ext Balasubramanian Manoharan
>>>             > Sent: Monday, October 06, 2014 7:16 PM
>>>             > To: lng-odp@lists.linaro.org
>>>         <mailto:lng-odp@lists.linaro.org>
>>>         <mailto:lng-odp@lists.linaro.org
>>>         <mailto:lng-odp@lists.linaro.org>>
>>>             > Subject: [lng-odp] [ODP/PATCH v6] API support for
>>>         querying mac
>>>             address
>>>             >
>>>             > This patch contains API support for querying mac address
>>>         using
>>>             odp_pktio_t
>>>             > handle
>>>             > This patch incorporates the latest ODP_ERR and ODP_ABORT
>>>         changes
>>>             done in
>>>             > linux-generic repo
>>>             >
>>>             > Signed-off-by: Balasubramanian Manoharan
>>>             <bala.manoharan@linaro.org
>>>         <mailto:bala.manoharan@linaro.org>
>>>         <mailto:bala.manoharan@linaro.org
>>>
>>>
>>>         <mailto:bala.manoharan@linaro.org>>>
>>>             > ---
>>>             >  example/ipsec/odp_ipsec.c   |  9 ++++++--
>>>             > platform/linux-generic/include/api/odp_packet_io.h | 17
>>>             +++++++++++++++
>>>             >  platform/linux-generic/odp_packet_io.c    | 24
>>>             > ++++++++++++++++++++++
>>>             >  platform/linux-generic/odp_packet_socket.c    | 16
>>>         ++++++++++-----
>>>             >  4 files changed, 59 insertions(+), 7 deletions(-)
>>>             >
>>>             > diff --git a/example/ipsec/odp_ipsec.c
>>>         b/example/ipsec/odp_ipsec.c
>>>             > index ec6c87a..9a46a0c 100644
>>>             > --- a/example/ipsec/odp_ipsec.c
>>>             > +++ b/example/ipsec/odp_ipsec.c
>>>             > @@ -549,7 +549,8 @@ void initialize_intf(char *intf)
>>>             >       char inq_name[ODP_QUEUE_NAME_LEN];
>>>             >       odp_queue_param_t qparam;
>>>             >       int ret;
>>>             > -     uint8_t src_mac[ODPH_ETHADDR_LEN];
>>>             > +     uint8_t src_mac[ODP_MAC_ADDR_MAX_LENGTH];
>>>
>>>             I think a helper definition should be used here. I'd not
>>>         include
>>>             protocol definitions/types into the main ODP API.
>>>
>>>         I wanted a design to help the platform decide the maximum size
>>>         of MAC_ADDR supported. Any approach is fine.
>>>
>>>
>>>
>>>             > +     size_t mac_addr_size;
>>>             >       char src_mac_str[MAX_STRING];
>>>             >
>>>             >       /*
>>>             > @@ -587,8 +588,12 @@ void initialize_intf(char *intf)
>>>             >       /* Read the source MAC address for this interface */
>>>             >  #if USE_MAC_ADDR_HACK
>>>             >       ret = query_mac_address(intf, src_mac);
>>>             > +     (void)mac_addr_size;
>>>             >  #else
>>>             > -     ret = odp_pktio_get_mac_addr(pktio, src_mac);
>>>             > +     ret = odp_pktio_get_mac_addr(pktio, src_mac,
>>>         &mac_addr_size);
>>>             > +     if (mac_addr_size != ODPH_ETHADDR_LEN) {
>>>             > +             ODP_ABORT("Ethernet mac address length not
>>>             supported");
>>>             > +     }
>>>             >  #endif
>>>             >       if (ret) {
>>>             >               ODP_ERR("Error: failed during MAC address
>>>         get for
>>>             %s\n",
>>>             > intf);
>>>             > diff --git
>>>         a/platform/linux-generic/include/api/odp_packet_io.h
>>>             > b/platform/linux-generic/include/api/odp_packet_io.h
>>>             > index 29fd105..2086316 100644
>>>             > --- a/platform/linux-generic/include/api/odp_packet_io.h
>>>             > +++ b/platform/linux-generic/include/api/odp_packet_io.h
>>>             > @@ -125,6 +125,23 @@ void
>>>         odp_pktio_set_input(odp_packet_t pkt,
>>>             > odp_pktio_t id);
>>>             >   */
>>>             >  odp_pktio_t odp_pktio_get_input(odp_packet_t pkt);
>>>             >
>>>             > +/**
>>>             > + * Defines the maximum length of mac address supported
>>>         by this
>>>             platform
>>>             > + */
>>>             > +#define ODP_MAC_ADDR_MAX_LENGTH      ETH_ALEN
>>>             > +
>>>             > +/**
>>>             > + * Get mac address of the interface
>>>             > + *
>>>             > + * @param id         ODP packet IO handle
>>>             > + * @param mac_addr   Storage for Mac address of the
>>>         packet IO
>>>             interface
>>>             > + *                   Storage provided by the caller
>>>         should be equal
>>>             > + *                   to ODP_MAC_ADDR_MAX_LENGTH (filled by
>>>             function)
>>>
>>>             "filled by function" ==> output parameter
>>>
>>>             > + * @param addr_size  Size of the Mac address (filled by
>>>         function)
>>>
>>>             I think it would be more logical if this is input
>>>         parameter (==
>>>             sizeof(mac_addr)) and used for error checking. Function could
>>>             return the number of bytes copied (6 or 8) on success (and
>>>         0 on
>>>             failure). User should know beforehand how large MAC address
>>> to
>>>             expect, right?
>>>
>>>         I believe having the maximum MAC_ADDR length being defined by
>>>         the platform makes the application agnostic across different
>>>         platform implementations and different types of odp_pktio_t
>>>         instances.
>>>         Having the size being returned as a parameter seemed to be
>>>         more inline with current ODP API design.
>>>
>>>
>>>     Can mac addr be different size? I saw only 6 bytes macs. Not sure
>>>     if it can be different size. And if it can not be than we don't
>>>     need ODP_MAC_ADDR_MAX_LENGTH.
>>>
>>>     Maxim.
>>>
>>>             > + * @return  0 on success or -1 on error
>>>             > +**/
>>>             > +int odp_pktio_get_mac_addr(odp_pktio_t id, unsigned
>>>         char *mac_addr,
>>>             > +                        size_t *addr_size);
>>>
>>>             To be inline with other accessor functions "get" should be
>>>             dropped. What if an interface is configured to accept
>>>         multiple mac
>>>             addresses? Is this the default address (every interface
>>> should
>>>             have at least one mac address). How other MACs are
>>>         inquired? Or is
>>>             it part of classification then.
>>>
>>>         This API would return the default MAC addr of the instance.
>>>         Returning multiple mac addr which was assigned to a specific
>>>         interface could be done by classification.
>>>
>>>         Regards,
>>>         Bala
>>>
>>>
>>>
>>>             -Petri
>>>
>>>
>>>
>>>
>>>         _______________________________________________
>>>         lng-odp mailing list
>>>
>>>         lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>>>         http://lists.linaro.org/mailman/listinfo/lng-odp
>>>
>>>
>>>
>>>     _______________________________________________
>>>     lng-odp mailing list
>>>     lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>>>     http://lists.linaro.org/mailman/listinfo/lng-odp
>>>
>>>
>>>
>>> _______________________________________________
>>> lng-odp mailing list
>>> lng-odp@lists.linaro.org
>>> http://lists.linaro.org/mailman/listinfo/lng-odp
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> lng-odp mailing list
>>> lng-odp@lists.linaro.org
>>> http://lists.linaro.org/mailman/listinfo/lng-odp
>>>
>>
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
Gilad Ben-Yossef Oct. 14, 2014, 1:10 p.m. UTC | #13
The assumption that a pkt_io has a MAC address and a single one at that is pretty weird.
Sure, on board LAN and PCIe NIC cards or USB dongles have an eeprom with a factory MAC address - but your L2 switch doesn't have a MAC address per port and even many NICs support several MAC address to filter on (for example for multicast)
When I use this API - what is it am I asking? Which MAC was burned by the silicon vendor for this pkt_io, if it even has any? Which MAC is used right now to filter incoming frames by this pkt_io? These might not be the same due to multicast, promiscuous mode etc.
In a sense it seems to be more related to the Classifier API than pkt_io API. 

Gilad Ben-Yossef
Software Architect
EZchip Technologies Ltd.
37 Israel Pollak Ave, Kiryat Gat 82025 ,Israel
Tel: +972-4-959-6666 ext. 576, Fax: +972-8-681-1483 
Mobile: +972-52-826-0388, US Mobile: +1-973-826-0388
Email: giladb@ezchip.com, Web: http://www.ezchip.com

"Ethernet always wins."
        — Andy Bechtolsheim


> -----Original Message-----

> From: lng-odp-bounces@lists.linaro.org [mailto:lng-odp-

> bounces@lists.linaro.org] On Behalf Of Ciprian Barbu

> Sent: Tuesday, October 14, 2014 3:32 PM

> To: Bala Manoharan

> Cc: Savolainen, Petri (NSN - FI/Espoo); lng-odp@lists.linaro.org

> Subject: Re: [lng-odp] [ODP/PATCH v6] API support for querying mac

> address

> 

> On Mon, Oct 13, 2014 at 3:21 PM, Bala Manoharan

> <bala.manoharan@linaro.org> wrote:

> > Hi,

> >

> > ODP_MAX_MACADDR_SIZE was needed since we wanted this API to be

> compliant for

> > both 6 and 8 byte MAC address.

> > Since we are having odp_pktio_t as abstract application cannot assume

> the

> > mac address to be the size of Ethernet.

> > That was the whole point behind having an MAX size being defined by the

> > platform and returning the size as an output parameter.

> 

> It doesn't feel right to me to have a platform dependent

> MAX_MACADDR_SIZE. Sure it could be the size of the longest MAC address

> of the interfaces that exist on the board in question, but you still

> have USB ports that could be used to connect a whole range of devices,

> firewire like Ola mentioned and who knows what else. To limit

> ourselves to Ethernet devices is a safe bet, but can't we do more? I

> would suggest something similar to Petri's idea, pass the destination

> buffer and it's size and the API to return the number of bytes copied

> if that was enough, or the number of bytes necessary otherwise.

> Something like snprintf, but not assuming we're copying a readable

> string.

> 

> >

> > My proposal is to keep the mechanism to support any size of MAC address

> but

> > only implement the same for Ethernet in the ODP v1.0 so that there is

> no

> > change in the API signature when updating for v2.0

> >

> > Regards,

> > Bala

> >

> >

> > On 10 October 2014 19:41, Bill Fischofer <bill.fischofer@linaro.org>

> wrote:

> >>

> >> I agree.  The only protocols we're dealing with in ODP v1.0  are

> Ethernet

> >> and for that MACs follow the EUI-48 format so they are always 6 bytes

> in

> >> length.

> >>

> >> Bill

> >>

> >> On Fri, Oct 10, 2014 at 4:11 AM, Savolainen, Petri (NSN - FI/Espoo)

> >> <petri.savolainen@nsn.com> wrote:

> >>>

> >>> I think ODP_MAX_MACADDR_SIZE is not needed in API, if user gives

> >>> sizeof(mac_addr) and func returns size copied.  It can be added in

> eth

> >>> helper file though (e.g. ODPH_ETH_MACADDR_SIZE_MAX).

> >>>

> >>>

> >>>

> >>> It’s again a protocol definition that I’d rather leave out when

> possible.

> >>>

> >>>

> >>>

> >>> -Petri

> >>>

> >>>

> >>>

> >>>

> >>>

> >>> From: lng-odp-bounces@lists.linaro.org

> >>> [mailto:lng-odp-bounces@lists.linaro.org] On Behalf Of ext Bala

> Manoharan

> >>> Sent: Friday, October 10, 2014 10:00 AM

> >>> To: Maxim Uvarov

> >>> Cc: lng-odp@lists.linaro.org

> >>> Subject: Re: [lng-odp] [ODP/PATCH v6] API support for querying mac

> >>> address

> >>>

> >>>

> >>>

> >>> Hi,

> >>>

> >>>

> >>>

> >>> * I will change the ODP_MAX_MACADDR_SIZE as 8. where should this

> macro be

> >>> defined is it okay to have it in the current odp_packet_io.h header

> file.

> >>>

> >>> * I will change the name of the api from odp_pktio_get_mac_addr() to

> >>> odp_pktio_mac_addr()

> >>>

> >>> * I will incorporate anders comments also.

> >>>

> >>> Any other changes required for this patch?

> >>>

> >>> Regards,

> >>>

> >>> Bala

> >>>

> >>>

> >>>

> >>> On 9 October 2014 21:12, Maxim Uvarov <maxim.uvarov@linaro.org>

> wrote:

> >>>

> >>> On 10/09/2014 02:24 PM, Ola Liljedahl wrote:

> >>>

> >>> Some interface types use 64-bit MAC addresses (e.g. Firewire).

> >>>

> >>> I think the ODP API should specify a recommended buffer size (e.g.

> >>> #define ODP_MACADDR_SIZE 8) and then return the actual length of the

> return

> >>> MAC address.

> >>> The application passes a buffer and a buffer size (this could be 6 if

> the

> >>> application is sure that the interface uses a MAC48 address). If the

> buffer

> >>> size is too small for the actual MAC address, an error is returned

> (e.g.

> >>> -1).

> >>>

> >>> -- Ola

> >>>

> >>>

> >>> ETH_ALEN is 6. So looks like patch needed to be update.

> >>>

> >>> Maxim.

> >>>

> >>>

> >>> On 8 October 2014 19:08, Maxim Uvarov <maxim.uvarov@linaro.org

> >>> <mailto:maxim.uvarov@linaro.org>> wrote:

> >>>

> >>>     On 10/07/2014 11:47 AM, Bala Manoharan wrote:

> >>>

> >>>

> >>>

> >>>         On 7 October 2014 12:43, Savolainen, Petri (NSN - FI/Espoo)

> >>>         <petri.savolainen@nsn.com <mailto:petri.savolainen@nsn.com>

> >>>         <mailto:petri.savolainen@nsn.com

> >>>         <mailto:petri.savolainen@nsn.com>>> wrote:

> >>>

> >>>

> >>>

> >>>             > -----Original Message-----

> >>>             > From: lng-odp-bounces@lists.linaro.org

> >>>         <mailto:lng-odp-bounces@lists.linaro.org>

> >>>             <mailto:lng-odp-bounces@lists.linaro.org

> >>>         <mailto:lng-odp-bounces@lists.linaro.org>> [mailto:lng-odp-

> >>>         <mailto:lng-odp->

> >>>             <mailto:lng-odp- <mailto:lng-odp->>

> >>>             > bounces@lists.linaro.org

> >>>         <mailto:bounces@lists.linaro.org>

> >>>         <mailto:bounces@lists.linaro.org

> >>>         <mailto:bounces@lists.linaro.org>>] On

> >>>             Behalf Of ext Balasubramanian Manoharan

> >>>             > Sent: Monday, October 06, 2014 7:16 PM

> >>>             > To: lng-odp@lists.linaro.org

> >>>         <mailto:lng-odp@lists.linaro.org>

> >>>         <mailto:lng-odp@lists.linaro.org

> >>>         <mailto:lng-odp@lists.linaro.org>>

> >>>             > Subject: [lng-odp] [ODP/PATCH v6] API support for

> >>>         querying mac

> >>>             address

> >>>             >

> >>>             > This patch contains API support for querying mac

> address

> >>>         using

> >>>             odp_pktio_t

> >>>             > handle

> >>>             > This patch incorporates the latest ODP_ERR and

> ODP_ABORT

> >>>         changes

> >>>             done in

> >>>             > linux-generic repo

> >>>             >

> >>>             > Signed-off-by: Balasubramanian Manoharan

> >>>             <bala.manoharan@linaro.org

> >>>         <mailto:bala.manoharan@linaro.org>

> >>>         <mailto:bala.manoharan@linaro.org

> >>>

> >>>

> >>>         <mailto:bala.manoharan@linaro.org>>>

> >>>             > ---

> >>>             >  example/ipsec/odp_ipsec.c   |  9 ++++++--

> >>>             > platform/linux-generic/include/api/odp_packet_io.h | 17

> >>>             +++++++++++++++

> >>>             >  platform/linux-generic/odp_packet_io.c    | 24

> >>>             > ++++++++++++++++++++++

> >>>             >  platform/linux-generic/odp_packet_socket.c    | 16

> >>>         ++++++++++-----

> >>>             >  4 files changed, 59 insertions(+), 7 deletions(-)

> >>>             >

> >>>             > diff --git a/example/ipsec/odp_ipsec.c

> >>>         b/example/ipsec/odp_ipsec.c

> >>>             > index ec6c87a..9a46a0c 100644

> >>>             > --- a/example/ipsec/odp_ipsec.c

> >>>             > +++ b/example/ipsec/odp_ipsec.c

> >>>             > @@ -549,7 +549,8 @@ void initialize_intf(char *intf)

> >>>             >       char inq_name[ODP_QUEUE_NAME_LEN];

> >>>             >       odp_queue_param_t qparam;

> >>>             >       int ret;

> >>>             > -     uint8_t src_mac[ODPH_ETHADDR_LEN];

> >>>             > +     uint8_t src_mac[ODP_MAC_ADDR_MAX_LENGTH];

> >>>

> >>>             I think a helper definition should be used here. I'd not

> >>>         include

> >>>             protocol definitions/types into the main ODP API.

> >>>

> >>>         I wanted a design to help the platform decide the maximum

> size

> >>>         of MAC_ADDR supported. Any approach is fine.

> >>>

> >>>

> >>>

> >>>             > +     size_t mac_addr_size;

> >>>             >       char src_mac_str[MAX_STRING];

> >>>             >

> >>>             >       /*

> >>>             > @@ -587,8 +588,12 @@ void initialize_intf(char *intf)

> >>>             >       /* Read the source MAC address for this interface

> */

> >>>             >  #if USE_MAC_ADDR_HACK

> >>>             >       ret = query_mac_address(intf, src_mac);

> >>>             > +     (void)mac_addr_size;

> >>>             >  #else

> >>>             > -     ret = odp_pktio_get_mac_addr(pktio, src_mac);

> >>>             > +     ret = odp_pktio_get_mac_addr(pktio, src_mac,

> >>>         &mac_addr_size);

> >>>             > +     if (mac_addr_size != ODPH_ETHADDR_LEN) {

> >>>             > +             ODP_ABORT("Ethernet mac address length

> not

> >>>             supported");

> >>>             > +     }

> >>>             >  #endif

> >>>             >       if (ret) {

> >>>             >               ODP_ERR("Error: failed during MAC address

> >>>         get for

> >>>             %s\n",

> >>>             > intf);

> >>>             > diff --git

> >>>         a/platform/linux-generic/include/api/odp_packet_io.h

> >>>             > b/platform/linux-generic/include/api/odp_packet_io.h

> >>>             > index 29fd105..2086316 100644

> >>>             > --- a/platform/linux-

> generic/include/api/odp_packet_io.h

> >>>             > +++ b/platform/linux-

> generic/include/api/odp_packet_io.h

> >>>             > @@ -125,6 +125,23 @@ void

> >>>         odp_pktio_set_input(odp_packet_t pkt,

> >>>             > odp_pktio_t id);

> >>>             >   */

> >>>             >  odp_pktio_t odp_pktio_get_input(odp_packet_t pkt);

> >>>             >

> >>>             > +/**

> >>>             > + * Defines the maximum length of mac address supported

> >>>         by this

> >>>             platform

> >>>             > + */

> >>>             > +#define ODP_MAC_ADDR_MAX_LENGTH      ETH_ALEN

> >>>             > +

> >>>             > +/**

> >>>             > + * Get mac address of the interface

> >>>             > + *

> >>>             > + * @param id         ODP packet IO handle

> >>>             > + * @param mac_addr   Storage for Mac address of the

> >>>         packet IO

> >>>             interface

> >>>             > + *                   Storage provided by the caller

> >>>         should be equal

> >>>             > + *                   to ODP_MAC_ADDR_MAX_LENGTH

> (filled by

> >>>             function)

> >>>

> >>>             "filled by function" ==> output parameter

> >>>

> >>>             > + * @param addr_size  Size of the Mac address (filled

> by

> >>>         function)

> >>>

> >>>             I think it would be more logical if this is input

> >>>         parameter (==

> >>>             sizeof(mac_addr)) and used for error checking. Function

> could

> >>>             return the number of bytes copied (6 or 8) on success

> (and

> >>>         0 on

> >>>             failure). User should know beforehand how large MAC

> address

> >>> to

> >>>             expect, right?

> >>>

> >>>         I believe having the maximum MAC_ADDR length being defined by

> >>>         the platform makes the application agnostic across different

> >>>         platform implementations and different types of odp_pktio_t

> >>>         instances.

> >>>         Having the size being returned as a parameter seemed to be

> >>>         more inline with current ODP API design.

> >>>

> >>>

> >>>     Can mac addr be different size? I saw only 6 bytes macs. Not sure

> >>>     if it can be different size. And if it can not be than we don't

> >>>     need ODP_MAC_ADDR_MAX_LENGTH.

> >>>

> >>>     Maxim.

> >>>

> >>>             > + * @return  0 on success or -1 on error

> >>>             > +**/

> >>>             > +int odp_pktio_get_mac_addr(odp_pktio_t id, unsigned

> >>>         char *mac_addr,

> >>>             > +                        size_t *addr_size);

> >>>

> >>>             To be inline with other accessor functions "get" should

> be

> >>>             dropped. What if an interface is configured to accept

> >>>         multiple mac

> >>>             addresses? Is this the default address (every interface

> >>> should

> >>>             have at least one mac address). How other MACs are

> >>>         inquired? Or is

> >>>             it part of classification then.

> >>>

> >>>         This API would return the default MAC addr of the instance.

> >>>         Returning multiple mac addr which was assigned to a specific

> >>>         interface could be done by classification.

> >>>

> >>>         Regards,

> >>>         Bala

> >>>

> >>>

> >>>

> >>>             -Petri

> >>>

> >>>

> >>>

> >>>

> >>>         _______________________________________________

> >>>         lng-odp mailing list

> >>>

> >>>         lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>

> >>>         http://lists.linaro.org/mailman/listinfo/lng-odp

> >>>

> >>>

> >>>

> >>>     _______________________________________________

> >>>     lng-odp mailing list

> >>>     lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>

> >>>     http://lists.linaro.org/mailman/listinfo/lng-odp

> >>>

> >>>

> >>>

> >>> _______________________________________________

> >>> lng-odp mailing list

> >>> lng-odp@lists.linaro.org

> >>> http://lists.linaro.org/mailman/listinfo/lng-odp

> >>>

> >>>

> >>>

> >>>

> >>> _______________________________________________

> >>> lng-odp mailing list

> >>> lng-odp@lists.linaro.org

> >>> http://lists.linaro.org/mailman/listinfo/lng-odp

> >>>

> >>

> >

> >

> > _______________________________________________

> > lng-odp mailing list

> > lng-odp@lists.linaro.org

> > http://lists.linaro.org/mailman/listinfo/lng-odp

> >

> 

> _______________________________________________

> lng-odp mailing list

> lng-odp@lists.linaro.org

> http://lists.linaro.org/mailman/listinfo/lng-odp
Balasubramanian Manoharan Oct. 23, 2014, 9:02 a.m. UTC | #14
Hi,

Sorry for the delayed reply,
This API points to the default mac address associated with pktio port.
This is useful incase if the application wants to know the mac address of
the interface in which it wants to send the packet out. Incase if the port
supports multiple mac address that can be handled an API added to the
classifier.

Regards,
Bala

On 14 October 2014 18:40, Gilad Ben Yossef <giladb@ezchip.com> wrote:

>
> The assumption that a pkt_io has a MAC address and a single one at that is
> pretty weird.
> Sure, on board LAN and PCIe NIC cards or USB dongles have an eeprom with a
> factory MAC address - but your L2 switch doesn't have a MAC address per
> port and even many NICs support several MAC address to filter on (for
> example for multicast)
> When I use this API - what is it am I asking? Which MAC was burned by the
> silicon vendor for this pkt_io, if it even has any? Which MAC is used right
> now to filter incoming frames by this pkt_io? These might not be the same
> due to multicast, promiscuous mode etc.
> In a sense it seems to be more related to the Classifier API than pkt_io
> API.
>
> Gilad Ben-Yossef
> Software Architect
> EZchip Technologies Ltd.
> 37 Israel Pollak Ave, Kiryat Gat 82025 ,Israel
> Tel: +972-4-959-6666 ext. 576, Fax: +972-8-681-1483
> Mobile: +972-52-826-0388, US Mobile: +1-973-826-0388
> Email: giladb@ezchip.com, Web: http://www.ezchip.com
>
> "Ethernet always wins."
>         — Andy Bechtolsheim
>
>
> > -----Original Message-----
> > From: lng-odp-bounces@lists.linaro.org [mailto:lng-odp-
> > bounces@lists.linaro.org] On Behalf Of Ciprian Barbu
> > Sent: Tuesday, October 14, 2014 3:32 PM
> > To: Bala Manoharan
> > Cc: Savolainen, Petri (NSN - FI/Espoo); lng-odp@lists.linaro.org
> > Subject: Re: [lng-odp] [ODP/PATCH v6] API support for querying mac
> > address
> >
> > On Mon, Oct 13, 2014 at 3:21 PM, Bala Manoharan
> > <bala.manoharan@linaro.org> wrote:
> > > Hi,
> > >
> > > ODP_MAX_MACADDR_SIZE was needed since we wanted this API to be
> > compliant for
> > > both 6 and 8 byte MAC address.
> > > Since we are having odp_pktio_t as abstract application cannot assume
> > the
> > > mac address to be the size of Ethernet.
> > > That was the whole point behind having an MAX size being defined by the
> > > platform and returning the size as an output parameter.
> >
> > It doesn't feel right to me to have a platform dependent
> > MAX_MACADDR_SIZE. Sure it could be the size of the longest MAC address
> > of the interfaces that exist on the board in question, but you still
> > have USB ports that could be used to connect a whole range of devices,
> > firewire like Ola mentioned and who knows what else. To limit
> > ourselves to Ethernet devices is a safe bet, but can't we do more? I
> > would suggest something similar to Petri's idea, pass the destination
> > buffer and it's size and the API to return the number of bytes copied
> > if that was enough, or the number of bytes necessary otherwise.
> > Something like snprintf, but not assuming we're copying a readable
> > string.
> >
> > >
> > > My proposal is to keep the mechanism to support any size of MAC address
> > but
> > > only implement the same for Ethernet in the ODP v1.0 so that there is
> > no
> > > change in the API signature when updating for v2.0
> > >
> > > Regards,
> > > Bala
> > >
> > >
> > > On 10 October 2014 19:41, Bill Fischofer <bill.fischofer@linaro.org>
> > wrote:
> > >>
> > >> I agree.  The only protocols we're dealing with in ODP v1.0  are
> > Ethernet
> > >> and for that MACs follow the EUI-48 format so they are always 6 bytes
> > in
> > >> length.
> > >>
> > >> Bill
> > >>
> > >> On Fri, Oct 10, 2014 at 4:11 AM, Savolainen, Petri (NSN - FI/Espoo)
> > >> <petri.savolainen@nsn.com> wrote:
> > >>>
> > >>> I think ODP_MAX_MACADDR_SIZE is not needed in API, if user gives
> > >>> sizeof(mac_addr) and func returns size copied.  It can be added in
> > eth
> > >>> helper file though (e.g. ODPH_ETH_MACADDR_SIZE_MAX).
> > >>>
> > >>>
> > >>>
> > >>> It’s again a protocol definition that I’d rather leave out when
> > possible.
> > >>>
> > >>>
> > >>>
> > >>> -Petri
> > >>>
> > >>>
> > >>>
> > >>>
> > >>>
> > >>> From: lng-odp-bounces@lists.linaro.org
> > >>> [mailto:lng-odp-bounces@lists.linaro.org] On Behalf Of ext Bala
> > Manoharan
> > >>> Sent: Friday, October 10, 2014 10:00 AM
> > >>> To: Maxim Uvarov
> > >>> Cc: lng-odp@lists.linaro.org
> > >>> Subject: Re: [lng-odp] [ODP/PATCH v6] API support for querying mac
> > >>> address
> > >>>
> > >>>
> > >>>
> > >>> Hi,
> > >>>
> > >>>
> > >>>
> > >>> * I will change the ODP_MAX_MACADDR_SIZE as 8. where should this
> > macro be
> > >>> defined is it okay to have it in the current odp_packet_io.h header
> > file.
> > >>>
> > >>> * I will change the name of the api from odp_pktio_get_mac_addr() to
> > >>> odp_pktio_mac_addr()
> > >>>
> > >>> * I will incorporate anders comments also.
> > >>>
> > >>> Any other changes required for this patch?
> > >>>
> > >>> Regards,
> > >>>
> > >>> Bala
> > >>>
> > >>>
> > >>>
> > >>> On 9 October 2014 21:12, Maxim Uvarov <maxim.uvarov@linaro.org>
> > wrote:
> > >>>
> > >>> On 10/09/2014 02:24 PM, Ola Liljedahl wrote:
> > >>>
> > >>> Some interface types use 64-bit MAC addresses (e.g. Firewire).
> > >>>
> > >>> I think the ODP API should specify a recommended buffer size (e.g.
> > >>> #define ODP_MACADDR_SIZE 8) and then return the actual length of the
> > return
> > >>> MAC address.
> > >>> The application passes a buffer and a buffer size (this could be 6 if
> > the
> > >>> application is sure that the interface uses a MAC48 address). If the
> > buffer
> > >>> size is too small for the actual MAC address, an error is returned
> > (e.g.
> > >>> -1).
> > >>>
> > >>> -- Ola
> > >>>
> > >>>
> > >>> ETH_ALEN is 6. So looks like patch needed to be update.
> > >>>
> > >>> Maxim.
> > >>>
> > >>>
> > >>> On 8 October 2014 19:08, Maxim Uvarov <maxim.uvarov@linaro.org
> > >>> <mailto:maxim.uvarov@linaro.org>> wrote:
> > >>>
> > >>>     On 10/07/2014 11:47 AM, Bala Manoharan wrote:
> > >>>
> > >>>
> > >>>
> > >>>         On 7 October 2014 12:43, Savolainen, Petri (NSN - FI/Espoo)
> > >>>         <petri.savolainen@nsn.com <mailto:petri.savolainen@nsn.com>
> > >>>         <mailto:petri.savolainen@nsn.com
> > >>>         <mailto:petri.savolainen@nsn.com>>> wrote:
> > >>>
> > >>>
> > >>>
> > >>>             > -----Original Message-----
> > >>>             > From: lng-odp-bounces@lists.linaro.org
> > >>>         <mailto:lng-odp-bounces@lists.linaro.org>
> > >>>             <mailto:lng-odp-bounces@lists.linaro.org
> > >>>         <mailto:lng-odp-bounces@lists.linaro.org>> [mailto:lng-odp-
> > >>>         <mailto:lng-odp->
> > >>>             <mailto:lng-odp- <mailto:lng-odp->>
> > >>>             > bounces@lists.linaro.org
> > >>>         <mailto:bounces@lists.linaro.org>
> > >>>         <mailto:bounces@lists.linaro.org
> > >>>         <mailto:bounces@lists.linaro.org>>] On
> > >>>             Behalf Of ext Balasubramanian Manoharan
> > >>>             > Sent: Monday, October 06, 2014 7:16 PM
> > >>>             > To: lng-odp@lists.linaro.org
> > >>>         <mailto:lng-odp@lists.linaro.org>
> > >>>         <mailto:lng-odp@lists.linaro.org
> > >>>         <mailto:lng-odp@lists.linaro.org>>
> > >>>             > Subject: [lng-odp] [ODP/PATCH v6] API support for
> > >>>         querying mac
> > >>>             address
> > >>>             >
> > >>>             > This patch contains API support for querying mac
> > address
> > >>>         using
> > >>>             odp_pktio_t
> > >>>             > handle
> > >>>             > This patch incorporates the latest ODP_ERR and
> > ODP_ABORT
> > >>>         changes
> > >>>             done in
> > >>>             > linux-generic repo
> > >>>             >
> > >>>             > Signed-off-by: Balasubramanian Manoharan
> > >>>             <bala.manoharan@linaro.org
> > >>>         <mailto:bala.manoharan@linaro.org>
> > >>>         <mailto:bala.manoharan@linaro.org
> > >>>
> > >>>
> > >>>         <mailto:bala.manoharan@linaro.org>>>
> > >>>             > ---
> > >>>             >  example/ipsec/odp_ipsec.c   |  9 ++++++--
> > >>>             > platform/linux-generic/include/api/odp_packet_io.h | 17
> > >>>             +++++++++++++++
> > >>>             >  platform/linux-generic/odp_packet_io.c    | 24
> > >>>             > ++++++++++++++++++++++
> > >>>             >  platform/linux-generic/odp_packet_socket.c    | 16
> > >>>         ++++++++++-----
> > >>>             >  4 files changed, 59 insertions(+), 7 deletions(-)
> > >>>             >
> > >>>             > diff --git a/example/ipsec/odp_ipsec.c
> > >>>         b/example/ipsec/odp_ipsec.c
> > >>>             > index ec6c87a..9a46a0c 100644
> > >>>             > --- a/example/ipsec/odp_ipsec.c
> > >>>             > +++ b/example/ipsec/odp_ipsec.c
> > >>>             > @@ -549,7 +549,8 @@ void initialize_intf(char *intf)
> > >>>             >       char inq_name[ODP_QUEUE_NAME_LEN];
> > >>>             >       odp_queue_param_t qparam;
> > >>>             >       int ret;
> > >>>             > -     uint8_t src_mac[ODPH_ETHADDR_LEN];
> > >>>             > +     uint8_t src_mac[ODP_MAC_ADDR_MAX_LENGTH];
> > >>>
> > >>>             I think a helper definition should be used here. I'd not
> > >>>         include
> > >>>             protocol definitions/types into the main ODP API.
> > >>>
> > >>>         I wanted a design to help the platform decide the maximum
> > size
> > >>>         of MAC_ADDR supported. Any approach is fine.
> > >>>
> > >>>
> > >>>
> > >>>             > +     size_t mac_addr_size;
> > >>>             >       char src_mac_str[MAX_STRING];
> > >>>             >
> > >>>             >       /*
> > >>>             > @@ -587,8 +588,12 @@ void initialize_intf(char *intf)
> > >>>             >       /* Read the source MAC address for this interface
> > */
> > >>>             >  #if USE_MAC_ADDR_HACK
> > >>>             >       ret = query_mac_address(intf, src_mac);
> > >>>             > +     (void)mac_addr_size;
> > >>>             >  #else
> > >>>             > -     ret = odp_pktio_get_mac_addr(pktio, src_mac);
> > >>>             > +     ret = odp_pktio_get_mac_addr(pktio, src_mac,
> > >>>         &mac_addr_size);
> > >>>             > +     if (mac_addr_size != ODPH_ETHADDR_LEN) {
> > >>>             > +             ODP_ABORT("Ethernet mac address length
> > not
> > >>>             supported");
> > >>>             > +     }
> > >>>             >  #endif
> > >>>             >       if (ret) {
> > >>>             >               ODP_ERR("Error: failed during MAC address
> > >>>         get for
> > >>>             %s\n",
> > >>>             > intf);
> > >>>             > diff --git
> > >>>         a/platform/linux-generic/include/api/odp_packet_io.h
> > >>>             > b/platform/linux-generic/include/api/odp_packet_io.h
> > >>>             > index 29fd105..2086316 100644
> > >>>             > --- a/platform/linux-
> > generic/include/api/odp_packet_io.h
> > >>>             > +++ b/platform/linux-
> > generic/include/api/odp_packet_io.h
> > >>>             > @@ -125,6 +125,23 @@ void
> > >>>         odp_pktio_set_input(odp_packet_t pkt,
> > >>>             > odp_pktio_t id);
> > >>>             >   */
> > >>>             >  odp_pktio_t odp_pktio_get_input(odp_packet_t pkt);
> > >>>             >
> > >>>             > +/**
> > >>>             > + * Defines the maximum length of mac address supported
> > >>>         by this
> > >>>             platform
> > >>>             > + */
> > >>>             > +#define ODP_MAC_ADDR_MAX_LENGTH      ETH_ALEN
> > >>>             > +
> > >>>             > +/**
> > >>>             > + * Get mac address of the interface
> > >>>             > + *
> > >>>             > + * @param id         ODP packet IO handle
> > >>>             > + * @param mac_addr   Storage for Mac address of the
> > >>>         packet IO
> > >>>             interface
> > >>>             > + *                   Storage provided by the caller
> > >>>         should be equal
> > >>>             > + *                   to ODP_MAC_ADDR_MAX_LENGTH
> > (filled by
> > >>>             function)
> > >>>
> > >>>             "filled by function" ==> output parameter
> > >>>
> > >>>             > + * @param addr_size  Size of the Mac address (filled
> > by
> > >>>         function)
> > >>>
> > >>>             I think it would be more logical if this is input
> > >>>         parameter (==
> > >>>             sizeof(mac_addr)) and used for error checking. Function
> > could
> > >>>             return the number of bytes copied (6 or 8) on success
> > (and
> > >>>         0 on
> > >>>             failure). User should know beforehand how large MAC
> > address
> > >>> to
> > >>>             expect, right?
> > >>>
> > >>>         I believe having the maximum MAC_ADDR length being defined by
> > >>>         the platform makes the application agnostic across different
> > >>>         platform implementations and different types of odp_pktio_t
> > >>>         instances.
> > >>>         Having the size being returned as a parameter seemed to be
> > >>>         more inline with current ODP API design.
> > >>>
> > >>>
> > >>>     Can mac addr be different size? I saw only 6 bytes macs. Not sure
> > >>>     if it can be different size. And if it can not be than we don't
> > >>>     need ODP_MAC_ADDR_MAX_LENGTH.
> > >>>
> > >>>     Maxim.
> > >>>
> > >>>             > + * @return  0 on success or -1 on error
> > >>>             > +**/
> > >>>             > +int odp_pktio_get_mac_addr(odp_pktio_t id, unsigned
> > >>>         char *mac_addr,
> > >>>             > +                        size_t *addr_size);
> > >>>
> > >>>             To be inline with other accessor functions "get" should
> > be
> > >>>             dropped. What if an interface is configured to accept
> > >>>         multiple mac
> > >>>             addresses? Is this the default address (every interface
> > >>> should
> > >>>             have at least one mac address). How other MACs are
> > >>>         inquired? Or is
> > >>>             it part of classification then.
> > >>>
> > >>>         This API would return the default MAC addr of the instance.
> > >>>         Returning multiple mac addr which was assigned to a specific
> > >>>         interface could be done by classification.
> > >>>
> > >>>         Regards,
> > >>>         Bala
> > >>>
> > >>>
> > >>>
> > >>>             -Petri
> > >>>
> > >>>
> > >>>
> > >>>
> > >>>         _______________________________________________
> > >>>         lng-odp mailing list
> > >>>
> > >>>         lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
> > >>>         http://lists.linaro.org/mailman/listinfo/lng-odp
> > >>>
> > >>>
> > >>>
> > >>>     _______________________________________________
> > >>>     lng-odp mailing list
> > >>>     lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
> > >>>     http://lists.linaro.org/mailman/listinfo/lng-odp
> > >>>
> > >>>
> > >>>
> > >>> _______________________________________________
> > >>> lng-odp mailing list
> > >>> lng-odp@lists.linaro.org
> > >>> http://lists.linaro.org/mailman/listinfo/lng-odp
> > >>>
> > >>>
> > >>>
> > >>>
> > >>> _______________________________________________
> > >>> lng-odp mailing list
> > >>> lng-odp@lists.linaro.org
> > >>> http://lists.linaro.org/mailman/listinfo/lng-odp
> > >>>
> > >>
> > >
> > >
> > > _______________________________________________
> > > lng-odp mailing list
> > > lng-odp@lists.linaro.org
> > > http://lists.linaro.org/mailman/listinfo/lng-odp
> > >
> >
> > _______________________________________________
> > lng-odp mailing list
> > lng-odp@lists.linaro.org
> > http://lists.linaro.org/mailman/listinfo/lng-odp
>
diff mbox

Patch

diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
index ec6c87a..9a46a0c 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -549,7 +549,8 @@  void initialize_intf(char *intf)
 	char inq_name[ODP_QUEUE_NAME_LEN];
 	odp_queue_param_t qparam;
 	int ret;
-	uint8_t src_mac[ODPH_ETHADDR_LEN];
+	uint8_t src_mac[ODP_MAC_ADDR_MAX_LENGTH];
+	size_t mac_addr_size;
 	char src_mac_str[MAX_STRING];
 
 	/*
@@ -587,8 +588,12 @@  void initialize_intf(char *intf)
 	/* Read the source MAC address for this interface */
 #if USE_MAC_ADDR_HACK
 	ret = query_mac_address(intf, src_mac);
+	(void)mac_addr_size;
 #else
-	ret = odp_pktio_get_mac_addr(pktio, src_mac);
+	ret = odp_pktio_get_mac_addr(pktio, src_mac, &mac_addr_size);
+	if (mac_addr_size != ODPH_ETHADDR_LEN) {
+		ODP_ABORT("Ethernet mac address length not supported");
+	}
 #endif
 	if (ret) {
 		ODP_ERR("Error: failed during MAC address get for %s\n", intf);
diff --git a/platform/linux-generic/include/api/odp_packet_io.h b/platform/linux-generic/include/api/odp_packet_io.h
index 29fd105..2086316 100644
--- a/platform/linux-generic/include/api/odp_packet_io.h
+++ b/platform/linux-generic/include/api/odp_packet_io.h
@@ -125,6 +125,23 @@  void odp_pktio_set_input(odp_packet_t pkt, odp_pktio_t id);
  */
 odp_pktio_t odp_pktio_get_input(odp_packet_t pkt);
 
+/**
+ * Defines the maximum length of mac address supported by this platform
+ */
+#define ODP_MAC_ADDR_MAX_LENGTH	ETH_ALEN
+
+/**
+ * Get mac address of the interface
+ *
+ * @param id		ODP packet IO handle
+ * @param mac_addr	Storage for Mac address of the packet IO interface
+ *			Storage provided by the caller should be equal
+ *			to ODP_MAC_ADDR_MAX_LENGTH (filled by function)
+ * @param addr_size	Size of the Mac address (filled by function)
+ * @return  0 on success or -1 on error
+**/
+int odp_pktio_get_mac_addr(odp_pktio_t id, unsigned char *mac_addr,
+			   size_t *addr_size);
 #ifdef __cplusplus
 }
 #endif
diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
index 0c30f0f..409438c 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -476,3 +476,27 @@  int pktin_deq_multi(queue_entry_t *qentry, odp_buffer_hdr_t *buf_hdr[], int num)
 
 	return nbr;
 }
+int odp_pktio_get_mac_addr(odp_pktio_t id, unsigned char *mac_addr,
+			   size_t *addr_size)
+{
+	pktio_entry_t *pktio_entry = get_entry(id);
+	if (!pktio_entry) {
+		ODP_ERR("Invalid odp_pktio_t value\n");
+		return -1;
+	}
+	switch (pktio_entry->s.type) {
+	case ODP_PKTIO_TYPE_SOCKET_BASIC:
+	case ODP_PKTIO_TYPE_SOCKET_MMSG:
+		memcpy(mac_addr, pktio_entry->s.pkt_sock.if_mac, ETH_ALEN);
+		break;
+	case ODP_PKTIO_TYPE_SOCKET_MMAP:
+		memcpy(mac_addr, pktio_entry->s.pkt_sock_mmap.if_mac, ETH_ALEN);
+		break;
+	default:
+		ODP_ERR("Invalid pktio type: %02x\n",
+			pktio_entry->s.type);
+		return -1;
+	}
+	*addr_size = ETH_ALEN;
+	return 0;
+}
diff --git a/platform/linux-generic/odp_packet_socket.c b/platform/linux-generic/odp_packet_socket.c
index 006d7bd..03f67cc 100644
--- a/platform/linux-generic/odp_packet_socket.c
+++ b/platform/linux-generic/odp_packet_socket.c
@@ -89,6 +89,8 @@  typedef struct {
 
 static raw_socket_t raw_sockets[MAX_RAW_SOCKETS_NETDEVS];
 static odp_spinlock_t raw_sockets_lock;
+static int socket_store_hw_addr(int sockfd, unsigned char *if_mac,
+			      const char *netdev);
 
 /** Eth buffer start offset from u32-aligned address to make sure the following
  * header (e.g. IP) starts at a 32-bit aligned address.
@@ -206,13 +208,17 @@  int setup_pkt_sock(pkt_sock_t *const pkt_sock, const char *netdev,
 	sockfd = find_raw_fd(netdev);
 	if (sockfd) {
 		pkt_sock->sockfd = sockfd;
+		if (socket_store_hw_addr(sockfd, pkt_sock->if_mac, netdev)) {
+			ODP_ERR("setup_pkt_sock() - socket_store_hw_addr()");
+			goto error;
+		}
 		odp_spinlock_unlock(&raw_sockets_lock);
 		return sockfd;
 	}
 
 	sockfd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
 	if (sockfd == -1) {
-		perror("setup_pkt_sock() - socket()");
+		ODP_ERR("setup_pkt_sock() - socket()");
 		goto error;
 	}
 	pkt_sock->sockfd = sockfd;
@@ -778,7 +784,7 @@  static int mmap_bind_sock(pkt_sock_mmap_t *pkt_sock, const char *netdev)
 	return 0;
 }
 
-static int mmap_store_hw_addr(pkt_sock_mmap_t *const pkt_sock,
+static int socket_store_hw_addr(int sockfd, unsigned char *if_mac,
 			      const char *netdev)
 {
 	struct ifreq ethreq;
@@ -787,13 +793,13 @@  static int mmap_store_hw_addr(pkt_sock_mmap_t *const pkt_sock,
 	/* get MAC address */
 	memset(&ethreq, 0, sizeof(ethreq));
 	strncpy(ethreq.ifr_name, netdev, IFNAMSIZ-1);
-	ret = ioctl(pkt_sock->sockfd, SIOCGIFHWADDR, &ethreq);
+	ret = ioctl(sockfd, SIOCGIFHWADDR, &ethreq);
 	if (ret != 0) {
 		perror("store_hw_addr() - ioctl(SIOCGIFHWADDR)");
 		return -1;
 	}
 
-	ethaddr_copy(pkt_sock->if_mac,
+	ethaddr_copy(if_mac,
 		     (unsigned char *)ethreq.ifr_ifru.ifru_hwaddr.sa_data);
 
 	return 0;
@@ -848,7 +854,7 @@  int setup_pkt_sock_mmap(pkt_sock_mmap_t *const pkt_sock, const char *netdev,
 	if (ret != 0)
 		return -1;
 
-	ret = mmap_store_hw_addr(pkt_sock, netdev);
+	ret = socket_store_hw_addr(pkt_sock->sockfd, pkt_sock->if_mac, netdev);
 	if (ret != 0)
 		return -1;