diff mbox

[2/2] linux-generic: odp_pktio_open loop0 support

Message ID 1416932669-2053-2-git-send-email-maxim.uvarov@linaro.org
State New
Headers show

Commit Message

Maxim Uvarov Nov. 25, 2014, 4:24 p.m. UTC
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
---
 platform/linux-generic/odp_packet_io.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

Comments

Alexandru Badicioiu Nov. 26, 2014, 8:39 a.m. UTC | #1
This patch has no description. The title is not self explanatory either.
Also the existence of eth0 should be verified  before mapping the loop0 to
eth0 - some platforms may use other interface names (e.g. fmX-gby for FSL
DPAA platforms).  I think a better solution would be to enumerate the
available interfaces  and pick a suitable one.


On 25 November 2014 at 18:24, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:

> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
> ---
>  platform/linux-generic/odp_packet_io.c | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
>
> diff --git a/platform/linux-generic/odp_packet_io.c
> b/platform/linux-generic/odp_packet_io.c
> index c523350..501b2e9 100644
> --- a/platform/linux-generic/odp_packet_io.c
> +++ b/platform/linux-generic/odp_packet_io.c
> @@ -156,6 +156,33 @@ odp_pktio_t odp_pktio_open(const char *dev,
> odp_buffer_pool_t pool)
>         pktio_entry_t *pktio_entry;
>         int res;
>         int fanout = 1;
> +       char loop0[IFNAMSIZ] = "eth0"; /* linux-generic loop0 device*/
> +       char *loop_hint;
> +
> +       if (strlen(dev) > IFNAMSIZ) {
> +               /* ioctl names limitation */
> +               ODP_ERR("pktio name %s is too big, limit is %d bytes\n",
> +                       dev, IFNAMSIZ);
> +               return ODP_PKTIO_INVALID;
> +       }
> +
> +       loop_hint = getenv("ODP_PKTIO_LOOPDEV");
> +       if (!strncmp(dev, "loop0", 5)) {
> +               if (loop_hint && (strlen(loop_hint) > 0)) {
> +                       if (strlen(loop_hint) > IFNAMSIZ) {
> +                               ODP_ERR("pktio name %s is too big, limit
> is %d bytes\n",
> +                                       loop_hint, IFNAMSIZ);
> +                               return ODP_PKTIO_INVALID;
> +                       }
> +
> +                       memset(loop0, 0, IFNAMSIZ);
> +                       memcpy(loop0, loop_hint, strlen(loop_hint));
> +                       ODP_DBG("pktio rename loop0 to %s\n", loop_hint);
> +               } else {
> +                       ODP_DBG("pktio rename loop0 to eth0\n");
> +                       dev = loop0;
> +               }
> +       }
>
>         id = alloc_lock_pktio_entry();
>         if (id == ODP_PKTIO_INVALID) {
> --
> 1.8.5.1.163.gd7aced9
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
Ola Liljedahl Nov. 26, 2014, 9:25 a.m. UTC | #2
On 26 November 2014 at 09:39, Alexandru Badicioiu
<alexandru.badicioiu@linaro.org> wrote:
> This patch has no description. The title is not self explanatory either.
> Also the existence of eth0 should be verified  before mapping the loop0 to
> eth0 - some platforms may use other interface names (e.g. fmX-gby for FSL
> DPAA platforms).  I think a better solution would be to enumerate the
> available interfaces  and pick a suitable one.
I second that opinion. On my ChromeBook (great development
platforms!), the only Ethernet-like
interface is called mlan0.

>
>
> On 25 November 2014 at 18:24, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:
>>
>> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
>> ---
>>  platform/linux-generic/odp_packet_io.c | 27 +++++++++++++++++++++++++++
>>  1 file changed, 27 insertions(+)
>>
>> diff --git a/platform/linux-generic/odp_packet_io.c
>> b/platform/linux-generic/odp_packet_io.c
>> index c523350..501b2e9 100644
>> --- a/platform/linux-generic/odp_packet_io.c
>> +++ b/platform/linux-generic/odp_packet_io.c
>> @@ -156,6 +156,33 @@ odp_pktio_t odp_pktio_open(const char *dev,
>> odp_buffer_pool_t pool)
>>         pktio_entry_t *pktio_entry;
>>         int res;
>>         int fanout = 1;
>> +       char loop0[IFNAMSIZ] = "eth0"; /* linux-generic loop0 device*/
This comment is strange. If ODP uses an interface like "eth0", how can
that be a loopback interface?
Won't packet I/O using this interface be mapped onto the real Ethernet
interface and sent onto the physical link?

-- Ola

>> +       char *loop_hint;
>> +
>> +       if (strlen(dev) > IFNAMSIZ) {
>> +               /* ioctl names limitation */
>> +               ODP_ERR("pktio name %s is too big, limit is %d bytes\n",
>> +                       dev, IFNAMSIZ);
>> +               return ODP_PKTIO_INVALID;
>> +       }
>> +
>> +       loop_hint = getenv("ODP_PKTIO_LOOPDEV");
>> +       if (!strncmp(dev, "loop0", 5)) {
>> +               if (loop_hint && (strlen(loop_hint) > 0)) {
>> +                       if (strlen(loop_hint) > IFNAMSIZ) {
>> +                               ODP_ERR("pktio name %s is too big, limit
>> is %d bytes\n",
>> +                                       loop_hint, IFNAMSIZ);
>> +                               return ODP_PKTIO_INVALID;
>> +                       }
>> +
>> +                       memset(loop0, 0, IFNAMSIZ);
>> +                       memcpy(loop0, loop_hint, strlen(loop_hint));
>> +                       ODP_DBG("pktio rename loop0 to %s\n", loop_hint);
>> +               } else {
>> +                       ODP_DBG("pktio rename loop0 to eth0\n");
>> +                       dev = loop0;
>> +               }
>> +       }
>>
>>         id = alloc_lock_pktio_entry();
>>         if (id == ODP_PKTIO_INVALID) {
>> --
>> 1.8.5.1.163.gd7aced9
>>
>>
>> _______________________________________________
>> 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 Nov. 26, 2014, 11:53 a.m. UTC | #3
On 11/26/2014 12:25 PM, Ola Liljedahl wrote:
> On 26 November 2014 at 09:39, Alexandru Badicioiu
> <alexandru.badicioiu@linaro.org> wrote:
>> This patch has no description. The title is not self explanatory either.
>> Also the existence of eth0 should be verified  before mapping the loop0 to
>> eth0 - some platforms may use other interface names (e.g. fmX-gby for FSL
>> DPAA platforms).  I think a better solution would be to enumerate the
>> available interfaces  and pick a suitable one.
> I second that opinion. On my ChromeBook (great development
> platforms!), the only Ethernet-like
> interface is called mlan0.
Hm, renaming should be done to some predictable name. eth0 is very 
common for linux.
If it's not so that can be changed with export ODP_PKTIO_LOOPDEV="mlan0".

I can walk over the list but not sure how to select interface that can 
be used.

Maxim.


>
>>
>> On 25 November 2014 at 18:24, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:
>>> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
>>> ---
>>>   platform/linux-generic/odp_packet_io.c | 27 +++++++++++++++++++++++++++
>>>   1 file changed, 27 insertions(+)
>>>
>>> diff --git a/platform/linux-generic/odp_packet_io.c
>>> b/platform/linux-generic/odp_packet_io.c
>>> index c523350..501b2e9 100644
>>> --- a/platform/linux-generic/odp_packet_io.c
>>> +++ b/platform/linux-generic/odp_packet_io.c
>>> @@ -156,6 +156,33 @@ odp_pktio_t odp_pktio_open(const char *dev,
>>> odp_buffer_pool_t pool)
>>>          pktio_entry_t *pktio_entry;
>>>          int res;
>>>          int fanout = 1;
>>> +       char loop0[IFNAMSIZ] = "eth0"; /* linux-generic loop0 device*/
> This comment is strange. If ODP uses an interface like "eth0", how can
> that be a loopback interface?
> Won't packet I/O using this interface be mapped onto the real Ethernet
> interface and sent onto the physical link?
>
> -- Ola
>
>>> +       char *loop_hint;
>>> +
>>> +       if (strlen(dev) > IFNAMSIZ) {
>>> +               /* ioctl names limitation */
>>> +               ODP_ERR("pktio name %s is too big, limit is %d bytes\n",
>>> +                       dev, IFNAMSIZ);
>>> +               return ODP_PKTIO_INVALID;
>>> +       }
>>> +
>>> +       loop_hint = getenv("ODP_PKTIO_LOOPDEV");
>>> +       if (!strncmp(dev, "loop0", 5)) {
>>> +               if (loop_hint && (strlen(loop_hint) > 0)) {
>>> +                       if (strlen(loop_hint) > IFNAMSIZ) {
>>> +                               ODP_ERR("pktio name %s is too big, limit
>>> is %d bytes\n",
>>> +                                       loop_hint, IFNAMSIZ);
>>> +                               return ODP_PKTIO_INVALID;
>>> +                       }
>>> +
>>> +                       memset(loop0, 0, IFNAMSIZ);
>>> +                       memcpy(loop0, loop_hint, strlen(loop_hint));
>>> +                       ODP_DBG("pktio rename loop0 to %s\n", loop_hint);
>>> +               } else {
>>> +                       ODP_DBG("pktio rename loop0 to eth0\n");
>>> +                       dev = loop0;
>>> +               }
>>> +       }
>>>
>>>          id = alloc_lock_pktio_entry();
>>>          if (id == ODP_PKTIO_INVALID) {
>>> --
>>> 1.8.5.1.163.gd7aced9
>>>
>>>
>>> _______________________________________________
>>> 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
>>
Alexandru Badicioiu Nov. 26, 2014, 12:04 p.m. UTC | #4
On 26 November 2014 at 13:53, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:

> On 11/26/2014 12:25 PM, Ola Liljedahl wrote:
>
>> On 26 November 2014 at 09:39, Alexandru Badicioiu
>> <alexandru.badicioiu@linaro.org> wrote:
>>
>>> This patch has no description. The title is not self explanatory either.
>>> Also the existence of eth0 should be verified  before mapping the loop0
>>> to
>>> eth0 - some platforms may use other interface names (e.g. fmX-gby for FSL
>>> DPAA platforms).  I think a better solution would be to enumerate the
>>> available interfaces  and pick a suitable one.
>>>
>> I second that opinion. On my ChromeBook (great development
>> platforms!), the only Ethernet-like
>> interface is called mlan0.
>>
> Hm, renaming should be done to some predictable name. eth0 is very common
> for linux.
> If it's not so that can be changed with export ODP_PKTIO_LOOPDEV="mlan0".
>
> I can walk over the list but not sure how to select interface that can be
> used.

[Alex] Then how the eth0 was selected in the first place?

>
>
> Maxim.
>
>
>
>
>>
>>> On 25 November 2014 at 18:24, Maxim Uvarov <maxim.uvarov@linaro.org>
>>> wrote:
>>>
>>>> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
>>>> ---
>>>>   platform/linux-generic/odp_packet_io.c | 27
>>>> +++++++++++++++++++++++++++
>>>>   1 file changed, 27 insertions(+)
>>>>
>>>> diff --git a/platform/linux-generic/odp_packet_io.c
>>>> b/platform/linux-generic/odp_packet_io.c
>>>> index c523350..501b2e9 100644
>>>> --- a/platform/linux-generic/odp_packet_io.c
>>>> +++ b/platform/linux-generic/odp_packet_io.c
>>>> @@ -156,6 +156,33 @@ odp_pktio_t odp_pktio_open(const char *dev,
>>>> odp_buffer_pool_t pool)
>>>>          pktio_entry_t *pktio_entry;
>>>>          int res;
>>>>          int fanout = 1;
>>>> +       char loop0[IFNAMSIZ] = "eth0"; /* linux-generic loop0 device*/
>>>>
>>> This comment is strange. If ODP uses an interface like "eth0", how can
>> that be a loopback interface?
>> Won't packet I/O using this interface be mapped onto the real Ethernet
>> interface and sent onto the physical link?
>>
>> -- Ola
>>
>>  +       char *loop_hint;
>>>> +
>>>> +       if (strlen(dev) > IFNAMSIZ) {
>>>> +               /* ioctl names limitation */
>>>> +               ODP_ERR("pktio name %s is too big, limit is %d bytes\n",
>>>> +                       dev, IFNAMSIZ);
>>>> +               return ODP_PKTIO_INVALID;
>>>> +       }
>>>> +
>>>> +       loop_hint = getenv("ODP_PKTIO_LOOPDEV");
>>>> +       if (!strncmp(dev, "loop0", 5)) {
>>>> +               if (loop_hint && (strlen(loop_hint) > 0)) {
>>>> +                       if (strlen(loop_hint) > IFNAMSIZ) {
>>>> +                               ODP_ERR("pktio name %s is too big, limit
>>>> is %d bytes\n",
>>>> +                                       loop_hint, IFNAMSIZ);
>>>> +                               return ODP_PKTIO_INVALID;
>>>> +                       }
>>>> +
>>>> +                       memset(loop0, 0, IFNAMSIZ);
>>>> +                       memcpy(loop0, loop_hint, strlen(loop_hint));
>>>> +                       ODP_DBG("pktio rename loop0 to %s\n",
>>>> loop_hint);
>>>> +               } else {
>>>> +                       ODP_DBG("pktio rename loop0 to eth0\n");
>>>> +                       dev = loop0;
>>>> +               }
>>>> +       }
>>>>
>>>>          id = alloc_lock_pktio_entry();
>>>>          if (id == ODP_PKTIO_INVALID) {
>>>> --
>>>> 1.8.5.1.163.gd7aced9
>>>>
>>>>
>>>> _______________________________________________
>>>> 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
>>>
>>>
>
Alexandru Badicioiu Nov. 26, 2014, 1:26 p.m. UTC | #5
On 26 November 2014 at 15:23, Jerin Jacob <jerin.jacob@caviumnetworks.com>
wrote:

> On Wed, Nov 26, 2014 at 02:53:50PM +0300, Maxim Uvarov wrote:
> > On 11/26/2014 12:25 PM, Ola Liljedahl wrote:
> > >On 26 November 2014 at 09:39, Alexandru Badicioiu
> > ><alexandru.badicioiu@linaro.org> wrote:
> > >>This patch has no description. The title is not self explanatory
> either.
> > >>Also the existence of eth0 should be verified  before mapping the
> loop0 to
> > >>eth0 - some platforms may use other interface names (e.g. fmX-gby for
> FSL
> > >>DPAA platforms).  I think a better solution would be to enumerate the
> > >>available interfaces  and pick a suitable one.
> > >I second that opinion. On my ChromeBook (great development
> > >platforms!), the only Ethernet-like
> > >interface is called mlan0.
> > Hm, renaming should be done to some predictable name. eth0 is very common
> > for linux.
> > If it's not so that can be changed with export ODP_PKTIO_LOOPDEV="mlan0".
> >
> > I can walk over the list but not sure how to select interface that can be
> > used.
>
> IMO we should  have an ODP API to enumerate all the available pktio ports
> in a given platform as strings along with a bitmap to represent their
> capability(like PKTIO_CAP_LOOPBACK)
> So that application can choose the pktio based on the capability.
> We can use our odp_xxxx_xxxx_next API model for enumeration.

[Alex] I share this opinion too.


> >
> > Maxim.
> >
> >
> > >
> > >>
> > >>On 25 November 2014 at 18:24, Maxim Uvarov <maxim.uvarov@linaro.org>
> wrote:
> > >>>Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
> > >>>---
> > >>>  platform/linux-generic/odp_packet_io.c | 27
> +++++++++++++++++++++++++++
> > >>>  1 file changed, 27 insertions(+)
> > >>>
> > >>>diff --git a/platform/linux-generic/odp_packet_io.c
> > >>>b/platform/linux-generic/odp_packet_io.c
> > >>>index c523350..501b2e9 100644
> > >>>--- a/platform/linux-generic/odp_packet_io.c
> > >>>+++ b/platform/linux-generic/odp_packet_io.c
> > >>>@@ -156,6 +156,33 @@ odp_pktio_t odp_pktio_open(const char *dev,
> > >>>odp_buffer_pool_t pool)
> > >>>         pktio_entry_t *pktio_entry;
> > >>>         int res;
> > >>>         int fanout = 1;
> > >>>+       char loop0[IFNAMSIZ] = "eth0"; /* linux-generic loop0 device*/
> > >This comment is strange. If ODP uses an interface like "eth0", how can
> > >that be a loopback interface?
> > >Won't packet I/O using this interface be mapped onto the real Ethernet
> > >interface and sent onto the physical link?
> > >
> > >-- Ola
> > >
> > >>>+       char *loop_hint;
> > >>>+
> > >>>+       if (strlen(dev) > IFNAMSIZ) {
> > >>>+               /* ioctl names limitation */
> > >>>+               ODP_ERR("pktio name %s is too big, limit is %d
> bytes\n",
> > >>>+                       dev, IFNAMSIZ);
> > >>>+               return ODP_PKTIO_INVALID;
> > >>>+       }
> > >>>+
> > >>>+       loop_hint = getenv("ODP_PKTIO_LOOPDEV");
> > >>>+       if (!strncmp(dev, "loop0", 5)) {
> > >>>+               if (loop_hint && (strlen(loop_hint) > 0)) {
> > >>>+                       if (strlen(loop_hint) > IFNAMSIZ) {
> > >>>+                               ODP_ERR("pktio name %s is too big,
> limit
> > >>>is %d bytes\n",
> > >>>+                                       loop_hint, IFNAMSIZ);
> > >>>+                               return ODP_PKTIO_INVALID;
> > >>>+                       }
> > >>>+
> > >>>+                       memset(loop0, 0, IFNAMSIZ);
> > >>>+                       memcpy(loop0, loop_hint, strlen(loop_hint));
> > >>>+                       ODP_DBG("pktio rename loop0 to %s\n",
> loop_hint);
> > >>>+               } else {
> > >>>+                       ODP_DBG("pktio rename loop0 to eth0\n");
> > >>>+                       dev = loop0;
> > >>>+               }
> > >>>+       }
> > >>>
> > >>>         id = alloc_lock_pktio_entry();
> > >>>         if (id == ODP_PKTIO_INVALID) {
> > >>>--
> > >>>1.8.5.1.163.gd7aced9
> > >>>
> > >>>
> > >>>_______________________________________________
> > >>>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
>
Taras Kondratiuk Nov. 26, 2014, 1:33 p.m. UTC | #6
On 11/26/2014 03:23 PM, Jerin Jacob wrote:
> On Wed, Nov 26, 2014 at 02:53:50PM +0300, Maxim Uvarov wrote:
>> On 11/26/2014 12:25 PM, Ola Liljedahl wrote:
>>> On 26 November 2014 at 09:39, Alexandru Badicioiu
>>> <alexandru.badicioiu@linaro.org> wrote:
>>>> This patch has no description. The title is not self explanatory either.
>>>> Also the existence of eth0 should be verified  before mapping the loop0 to
>>>> eth0 - some platforms may use other interface names (e.g. fmX-gby for FSL
>>>> DPAA platforms).  I think a better solution would be to enumerate the
>>>> available interfaces  and pick a suitable one.
>>> I second that opinion. On my ChromeBook (great development
>>> platforms!), the only Ethernet-like
>>> interface is called mlan0.
>> Hm, renaming should be done to some predictable name. eth0 is very common
>> for linux.
>> If it's not so that can be changed with export ODP_PKTIO_LOOPDEV="mlan0".
>>
>> I can walk over the list but not sure how to select interface that can be
>> used.
>
> IMO we should  have an ODP API to enumerate all the available pktio ports
> in a given platform as strings along with a bitmap to represent their capability(like PKTIO_CAP_LOOPBACK)
> So that application can choose the pktio based on the capability.
> We can use our odp_xxxx_xxxx_next API model for enumeration.

+1

Instead of bitmap it can some struct.
Maxim Uvarov Nov. 26, 2014, 2:05 p.m. UTC | #7
On 11/26/2014 04:33 PM, Taras Kondratiuk wrote:
> On 11/26/2014 03:23 PM, Jerin Jacob wrote:
>> On Wed, Nov 26, 2014 at 02:53:50PM +0300, Maxim Uvarov wrote:
>>> On 11/26/2014 12:25 PM, Ola Liljedahl wrote:
>>>> On 26 November 2014 at 09:39, Alexandru Badicioiu
>>>> <alexandru.badicioiu@linaro.org> wrote:
>>>>> This patch has no description. The title is not self explanatory 
>>>>> either.
>>>>> Also the existence of eth0 should be verified  before mapping the 
>>>>> loop0 to
>>>>> eth0 - some platforms may use other interface names (e.g. fmX-gby 
>>>>> for FSL
>>>>> DPAA platforms).  I think a better solution would be to enumerate the
>>>>> available interfaces  and pick a suitable one.
>>>> I second that opinion. On my ChromeBook (great development
>>>> platforms!), the only Ethernet-like
>>>> interface is called mlan0.
>>> Hm, renaming should be done to some predictable name. eth0 is very 
>>> common
>>> for linux.
>>> If it's not so that can be changed with export 
>>> ODP_PKTIO_LOOPDEV="mlan0".
>>>
>>> I can walk over the list but not sure how to select interface that 
>>> can be
>>> used.
>>
>> IMO we should  have an ODP API to enumerate all the available pktio 
>> ports
>> in a given platform as strings along with a bitmap to represent their 
>> capability(like PKTIO_CAP_LOOPBACK)
>> So that application can choose the pktio based on the capability.
>> We can use our odp_xxxx_xxxx_next API model for enumeration.
>
> +1
>
> Instead of bitmap it can some struct.


Any hint how that can be implemented on linux-generic for v1?
Taras Kondratiuk Nov. 26, 2014, 2:32 p.m. UTC | #8
On 11/26/2014 04:05 PM, Maxim Uvarov wrote:
> On 11/26/2014 04:33 PM, Taras Kondratiuk wrote:
>> On 11/26/2014 03:23 PM, Jerin Jacob wrote:
>>> On Wed, Nov 26, 2014 at 02:53:50PM +0300, Maxim Uvarov wrote:
>>>> On 11/26/2014 12:25 PM, Ola Liljedahl wrote:
>>>>> On 26 November 2014 at 09:39, Alexandru Badicioiu
>>>>> <alexandru.badicioiu@linaro.org> wrote:
>>>>>> This patch has no description. The title is not self explanatory
>>>>>> either.
>>>>>> Also the existence of eth0 should be verified  before mapping the
>>>>>> loop0 to
>>>>>> eth0 - some platforms may use other interface names (e.g. fmX-gby
>>>>>> for FSL
>>>>>> DPAA platforms).  I think a better solution would be to enumerate the
>>>>>> available interfaces  and pick a suitable one.
>>>>> I second that opinion. On my ChromeBook (great development
>>>>> platforms!), the only Ethernet-like
>>>>> interface is called mlan0.
>>>> Hm, renaming should be done to some predictable name. eth0 is very
>>>> common
>>>> for linux.
>>>> If it's not so that can be changed with export
>>>> ODP_PKTIO_LOOPDEV="mlan0".
>>>>
>>>> I can walk over the list but not sure how to select interface that
>>>> can be
>>>> used.
>>>
>>> IMO we should  have an ODP API to enumerate all the available pktio
>>> ports
>>> in a given platform as strings along with a bitmap to represent their
>>> capability(like PKTIO_CAP_LOOPBACK)
>>> So that application can choose the pktio based on the capability.
>>> We can use our odp_xxxx_xxxx_next API model for enumeration.
>>
>> +1
>>
>> Instead of bitmap it can some struct.
>
>
> Any hint how that can be implemented on linux-generic for v1?

SIOCGIFCONF ioctl can be used to get a list of interfaces.
Or read /proc/net/dev directly. Then read flags with SIOCGIFFLAGS ioctl.

I'm not sure if we need this for v1.
Stuart Haslam Nov. 26, 2014, 4:18 p.m. UTC | #9
On Wed, Nov 26, 2014 at 04:32:43PM +0200, Taras Kondratiuk wrote:
> On 11/26/2014 04:05 PM, Maxim Uvarov wrote:
> >On 11/26/2014 04:33 PM, Taras Kondratiuk wrote:
> >>On 11/26/2014 03:23 PM, Jerin Jacob wrote:
> >>>On Wed, Nov 26, 2014 at 02:53:50PM +0300, Maxim Uvarov wrote:
> >>>>On 11/26/2014 12:25 PM, Ola Liljedahl wrote:
> >>>>>On 26 November 2014 at 09:39, Alexandru Badicioiu
> >>>>><alexandru.badicioiu@linaro.org> wrote:
> >>>>>>This patch has no description. The title is not self explanatory
> >>>>>>either.
> >>>>>>Also the existence of eth0 should be verified  before mapping the
> >>>>>>loop0 to
> >>>>>>eth0 - some platforms may use other interface names (e.g. fmX-gby
> >>>>>>for FSL
> >>>>>>DPAA platforms).  I think a better solution would be to enumerate the
> >>>>>>available interfaces  and pick a suitable one.
> >>>>>I second that opinion. On my ChromeBook (great development
> >>>>>platforms!), the only Ethernet-like
> >>>>>interface is called mlan0.
> >>>>Hm, renaming should be done to some predictable name. eth0 is very
> >>>>common
> >>>>for linux.
> >>>>If it's not so that can be changed with export
> >>>>ODP_PKTIO_LOOPDEV="mlan0".
> >>>>
> >>>>I can walk over the list but not sure how to select interface that
> >>>>can be
> >>>>used.
> >>>
> >>>IMO we should  have an ODP API to enumerate all the available pktio
> >>>ports
> >>>in a given platform as strings along with a bitmap to represent their
> >>>capability(like PKTIO_CAP_LOOPBACK)
> >>>So that application can choose the pktio based on the capability.
> >>>We can use our odp_xxxx_xxxx_next API model for enumeration.
> >>
> >>+1
> >>
> >>Instead of bitmap it can some struct.
> >
> >
> >Any hint how that can be implemented on linux-generic for v1?
> 
> SIOCGIFCONF ioctl can be used to get a list of interfaces.
> Or read /proc/net/dev directly. Then read flags with SIOCGIFFLAGS ioctl.
> 
> I'm not sure if we need this for v1.
>

I started doing some of this a couple of weeks back [1]. It's easy
enough to find the available interfaces but the difficult part is
figuring out if those interfaces can be used by ODP (I didn't get
that far), and how much of this is a system/implementation problem
vs being an application/user problem? For example I presume you'd
want to exclude management ports.. and messing with settings such as
MTU on shared interfaces (including "lo") is sure to cause problems.

Maybe you could filter out interfaces that have IPs assigned?..

Anyway, I think interface enumeration would be good to have but I
don't think it's needed for 1.0.

--
Stuart. 

[1] https://git.linaro.org/people/stuart.haslam/odp.git/commit/3671a175d82c51c825f28d103fcc8da152a233d3
Maxim Uvarov Nov. 27, 2014, 12:59 p.m. UTC | #10
On 11/26/2014 05:22 PM, Jerin Jacob wrote:
> On Wed, Nov 26, 2014 at 05:05:14PM +0300, Maxim Uvarov wrote:
>> On 11/26/2014 04:33 PM, Taras Kondratiuk wrote:
>>> On 11/26/2014 03:23 PM, Jerin Jacob wrote:
>>>> On Wed, Nov 26, 2014 at 02:53:50PM +0300, Maxim Uvarov wrote:
>>>>> On 11/26/2014 12:25 PM, Ola Liljedahl wrote:
>>>>>> On 26 November 2014 at 09:39, Alexandru Badicioiu
>>>>>> <alexandru.badicioiu@linaro.org> wrote:
>>>>>>> This patch has no description. The title is not self explanatory
>>>>>>> either.
>>>>>>> Also the existence of eth0 should be verified  before mapping the
>>>>>>> loop0 to
>>>>>>> eth0 - some platforms may use other interface names (e.g. fmX-gby
>>>>>>> for FSL
>>>>>>> DPAA platforms).  I think a better solution would be to enumerate the
>>>>>>> available interfaces  and pick a suitable one.
>>>>>> I second that opinion. On my ChromeBook (great development
>>>>>> platforms!), the only Ethernet-like
>>>>>> interface is called mlan0.
>>>>> Hm, renaming should be done to some predictable name. eth0 is very
>>>>> common
>>>>> for linux.
>>>>> If it's not so that can be changed with export
>>>>> ODP_PKTIO_LOOPDEV="mlan0".
>>>>>
>>>>> I can walk over the list but not sure how to select interface that can
>>>>> be
>>>>> used.
>>>> IMO we should  have an ODP API to enumerate all the available pktio
>>>> ports
>>>> in a given platform as strings along with a bitmap to represent their
>>>> capability(like PKTIO_CAP_LOOPBACK)
>>>> So that application can choose the pktio based on the capability.
>>>> We can use our odp_xxxx_xxxx_next API model for enumeration.
>>> +1
>>>
>>> Instead of bitmap it can some struct.
>>
>> Any hint how that can be implemented on linux-generic for v1?
> How about mapping to linux lo loopback device ?
>
> lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
>          inet 127.0.0.1  netmask 255.0.0.0
>          inet6 ::1  prefixlen 128  scopeid 0x10<host>
>          loop  txqueuelen 0  (Local Loopback)
>          RX packets 580  bytes 48524 (47.3 KiB)
>          RX errors 0  dropped 0  overruns 0  frame 0
>          TX packets 580  bytes 48524 (47.3 KiB)
>          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
>
>
>>
lo0 does not can be switched to promisc mode. And you can not get raw 
packets there to test classification.

Maxim.
diff mbox

Patch

diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
index c523350..501b2e9 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -156,6 +156,33 @@  odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool)
 	pktio_entry_t *pktio_entry;
 	int res;
 	int fanout = 1;
+	char loop0[IFNAMSIZ] = "eth0"; /* linux-generic loop0 device*/
+	char *loop_hint;
+
+	if (strlen(dev) > IFNAMSIZ) {
+		/* ioctl names limitation */
+		ODP_ERR("pktio name %s is too big, limit is %d bytes\n",
+			dev, IFNAMSIZ);
+		return ODP_PKTIO_INVALID;
+	}
+
+	loop_hint = getenv("ODP_PKTIO_LOOPDEV");
+	if (!strncmp(dev, "loop0", 5)) {
+		if (loop_hint && (strlen(loop_hint) > 0)) {
+			if (strlen(loop_hint) > IFNAMSIZ) {
+				ODP_ERR("pktio name %s is too big, limit is %d bytes\n",
+					loop_hint, IFNAMSIZ);
+				return ODP_PKTIO_INVALID;
+			}
+
+			memset(loop0, 0, IFNAMSIZ);
+			memcpy(loop0, loop_hint, strlen(loop_hint));
+			ODP_DBG("pktio rename loop0 to %s\n", loop_hint);
+		} else {
+			ODP_DBG("pktio rename loop0 to eth0\n");
+			dev = loop0;
+		}
+	}
 
 	id = alloc_lock_pktio_entry();
 	if (id == ODP_PKTIO_INVALID) {