OK, I didn't see anything in odp_packet_socket.c that would suggest that
the MMAP code is actually being used.  If it is, then we have proper
segmented packet I/O support in place in linux-generic and folks can play
around with it by simply making adjustments to
ODP_CONFIG_PACKET_BUF_LEN_MIN/MAX.

Regarding the MMAP frame size, that should also be controlled by
ODP_CONFIG_PACKET_BUF_LEN_MAX.  Stuart, is that something you'd like to
look into?

On Fri, Dec 19, 2014 at 4:00 AM, Stuart Haslam <[email protected]>
wrote:
>
> On Wed, Dec 17, 2014 at 11:16:25PM +0000, Bill Fischofer wrote:
> > Add segmented packet I/O support via sockets. RAW sockets limited to
> > single segment.
> >
> > Signed-off-by: Bill Fischofer <[email protected]>
> > ---
> >  platform/linux-generic/odp_packet_socket.c | 33
> +++++++++++++++++-------------
> >  1 file changed, 19 insertions(+), 14 deletions(-)
> >
> > diff --git a/platform/linux-generic/odp_packet_socket.c
> b/platform/linux-generic/odp_packet_socket.c
> > index 2849065..340da88 100644
> > --- a/platform/linux-generic/odp_packet_socket.c
> > +++ b/platform/linux-generic/odp_packet_socket.c
> > @@ -321,7 +321,8 @@ int recv_pkt_sock_basic(pkt_sock_t *const pkt_sock,
> >
> >       for (i = 0; i < len; i++) {
> >               if (odp_likely(pkt == ODP_PACKET_INVALID)) {
> > -                     pkt = _odp_packet_alloc(pkt_sock->pool);
> > +                     pkt = odp_packet_alloc(pkt_sock->pool,
> > +                                            pkt_sock->max_frame_len);
> >                       if (odp_unlikely(pkt == ODP_PACKET_INVALID))
> >                               break;
> >               }
> > @@ -339,7 +340,7 @@ int recv_pkt_sock_basic(pkt_sock_t *const pkt_sock,
> >                       continue;
> >
> >               /* Parse and set packet header data */
> > -             packet_set_len(pkt, recv_bytes);
> > +             odp_packet_pull_tail(pkt, pkt_sock->max_frame_len -
> recv_bytes);
> >               _odp_packet_parse(pkt);
> >
> >               pkt_table[nb_rx] = pkt;
> > @@ -418,7 +419,8 @@ int recv_pkt_sock_mmsg(pkt_sock_t *const pkt_sock,
> >       memset(msgvec, 0, sizeof(msgvec));
> >
> >       for (i = 0; i < (int)len; i++) {
> > -             pkt_table[i] = _odp_packet_alloc(pkt_sock->pool);
> > +             pkt_table[i] = odp_packet_alloc(pkt_sock->pool,
> > +                                             pkt_sock->max_frame_len);
> >               if (odp_unlikely(pkt_table[i] == ODP_PACKET_INVALID))
> >                       break;
> >
> > @@ -445,7 +447,9 @@ int recv_pkt_sock_mmsg(pkt_sock_t *const pkt_sock,
> >               }
> >
> >               /* Parse and set packet header data */
> > -             packet_set_len(pkt_table[i], msgvec[i].msg_len);
> > +             odp_packet_pull_tail(pkt_table[i],
> > +                                  pkt_sock->max_frame_len -
> > +                                  msgvec[i].msg_len);
> >               _odp_packet_parse(pkt_table[i]);
> >
> >               pkt_table[nb_rx] = pkt_table[i];
> > @@ -566,7 +570,6 @@ static inline unsigned pkt_mmap_v2_rx(int sock,
> struct ring *ring,
> >       uint8_t *pkt_buf;
> >       int pkt_len;
> >       struct ethhdr *eth_hdr;
> > -     uint8_t *l2_hdr;
> >       unsigned i = 0;
> >
> >       (void)sock;
> > @@ -591,13 +594,15 @@ static inline unsigned pkt_mmap_v2_rx(int sock,
> struct ring *ring,
> >                               continue;
> >                       }
> >
> > -                     pkt_table[i] = _odp_packet_alloc(pool);
> > +                     pkt_table[i] = odp_packet_alloc(pool, pkt_len);
> >                       if (odp_unlikely(pkt_table[i] ==
> ODP_PACKET_INVALID))
> >                               break;
> >
> > -                     packet_set_len(pkt_table[i], pkt_len);
> > -                     l2_hdr = odp_packet_data(pkt_table[i]);
> > -                     memcpy(l2_hdr, pkt_buf, pkt_len);
> > +                     if (odp_packet_copydata_in(pkt_table[i], 0,
> > +                                                pkt_len, pkt_buf) != 0)
> {
> > +                             odp_packet_free(pkt_table[i]);
> > +                             break;
> > +                     }
>
> By the way I think this also resolves this issue;
>
> http://lists.linaro.org/pipermail/lng-odp/2014-December/005811.html
>
> Well at least it should avoid the crash.
>
> --
> Stuart.
>
>
_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to