Message ID | 1414520348-27537-4-git-send-email-zoltan.kiss@linaro.org |
---|---|
State | New |
Headers | show |
Hello Zoltan, Thank you for taking time to look at this. I didn't know you were going to start working right away, otherwise I would have told you I made a mistake when I named the branches in my repository, the latest version is actually ovs_odp_patches (which was previously ovs_odp_patches_v3) not ovs_odp_patches_v2. Most of the changes in this patch series are valid, I updated to the renamed odph_packet_alloc and similar and that's about it, all the other stuff is needed. I'm going to rename ovs_odp_patches_v2 to ovs_odp_patches_old and I will remove it in a few days. I can still try to apply the patches but if you have more time can you please send an update based on ovs_odp_patches branch ? On Tue, Oct 28, 2014 at 8:19 PM, Zoltan Kiss <zoltan.kiss@linaro.org> wrote: > --- > lib/netdev-odp.c | 52 +++++++++++++++++++++++++++------------------------- > lib/netdev-odp.h | 6 +++--- > lib/ofpbuf.c | 2 +- > 3 files changed, 31 insertions(+), 29 deletions(-) > > diff --git a/lib/netdev-odp.c b/lib/netdev-odp.c > index 785dc06..f979743 100644 > --- a/lib/netdev-odp.c > +++ b/lib/netdev-odp.c > @@ -94,7 +94,7 @@ struct netdev_rxq_odp { > void > free_odp_buf(struct ofpbuf *b) > { > - odp_packet_free(b->odp_pkt); > + odph_packet_free(b->odp_pkt); > odp_buffer_free(b->odp_ofpbuf); > } > > @@ -102,7 +102,6 @@ int > odp_init(int argc, char *argv[]) > { > int result; > - int thr_id; > > if (strcmp(argv[1], "--odp")) > return 0; > @@ -110,14 +109,17 @@ odp_init(int argc, char *argv[]) > argc--; > argv++; > > - result = odp_init_global(); > + result = odp_init_global(NULL, NULL); > if (result) { > ODP_ERR("Error: ODP global init failed\n"); > return result; > } > > - thr_id = odp_thread_create(0); > - odp_init_local(thr_id); > + /* Init this thread */ > + if (odp_init_local()) { > + ODP_ERR("Error: ODP local init failed.\n"); > + exit(EXIT_FAILURE); > + } > > odp_initialized = 1; > > @@ -128,11 +130,13 @@ static int > odp_class_init(void) > { > void *pool_base; > + odp_shm_t shm; > int result = 0; > > /* create packet pool */ > - pool_base = odp_shm_reserve("shm_packet_pool", SHM_PKT_POOL_SIZE, > - ODP_CACHE_LINE_SIZE); > + shm = odp_shm_reserve("shm_packet_pool", SHM_PKT_POOL_SIZE, > + ODP_CACHE_LINE_SIZE, 0); > + pool_base = odp_shm_addr(shm); > > if (odp_unlikely(pool_base == NULL)) { > ODP_ERR("Error: ODP packet pool mem alloc failed\n"); > @@ -153,8 +157,9 @@ odp_class_init(void) > odp_buffer_pool_print(pool); > > /* create ofpbuf pool */ > - pool_base = odp_shm_reserve("shm_ofpbuf_pool", SHM_OFPBUF_POOL_SIZE, > - ODP_CACHE_LINE_SIZE); > + shm = odp_shm_reserve("shm_ofpbuf_pool", SHM_OFPBUF_POOL_SIZE, > + ODP_CACHE_LINE_SIZE, 0); > + pool_base = odp_shm_addr(shm); > > if (odp_unlikely(pool_base == NULL)) { > ODP_ERR("Error: ODP packet pool mem alloc failed\n"); > @@ -175,8 +180,9 @@ odp_class_init(void) > odp_buffer_pool_print(ofpbuf_pool); > > /* create pool for structures */ > - pool_base = odp_shm_reserve("shm_struct_pool", SHM_STRUCT_POOL_SIZE, > - ODP_CACHE_LINE_SIZE); > + shm = odp_shm_reserve("shm_struct_pool", SHM_STRUCT_POOL_SIZE, > + ODP_CACHE_LINE_SIZE, 0); > + pool_base = odp_shm_addr(shm); > > if (odp_unlikely(pool_base == NULL)) { > ODP_ERR("Error: ODP packet pool mem alloc failed\n"); > @@ -222,8 +228,6 @@ netdev_odp_construct(struct netdev *netdev_) > { > int err = 0; > char *odp_if; > - odp_pktio_params_t params; > - socket_params_t *sock_params = ¶ms.sock_params; > struct netdev_odp *netdev = netdev_odp_cast(netdev_); > odp_packet_t pkt; > > @@ -234,9 +238,7 @@ netdev_odp_construct(struct netdev *netdev_) > goto out_err; > } > > - sock_params->type = ODP_PKTIO_TYPE_SOCKET_BASIC; > - > - netdev->pktio = odp_pktio_open(odp_if, pool, ¶ms); > + netdev->pktio = odp_pktio_open(odp_if, pool); > > if (netdev->pktio == ODP_PKTIO_INVALID) { > ODP_ERR("Error: odp pktio failed\n"); > @@ -245,15 +247,15 @@ netdev_odp_construct(struct netdev *netdev_) > } > > netdev->pkt_pool = pool; > - pkt = odp_packet_alloc(netdev->pkt_pool); > - if (!odp_packet_is_valid(pkt)) { > + pkt = odph_packet_alloc(netdev->pkt_pool); > + if (!odph_packet_is_valid(pkt)) { > out_of_memory(); > goto out_err; > } > > - netdev->max_frame_len = odp_packet_buf_size(pkt); > + netdev->max_frame_len = odph_packet_buf_size(pkt); > > - odp_packet_free(pkt); > + odph_packet_free(pkt); > > ovs_mutex_init(&netdev->mutex); > > @@ -302,7 +304,7 @@ static int drop_err_pkts(odp_packet_t pkt_tbl[], unsigned len) > pkt = pkt_tbl[i]; > > if (odp_unlikely(odp_packet_error(pkt))) { > - odp_packet_free(pkt); /* Drop */ > + odph_packet_free(pkt); /* Drop */ > pkt_cnt--; > } else if (odp_unlikely(i != j++)) { > pkt_tbl[j-1] = pkt; > @@ -332,9 +334,9 @@ clone_pkts(struct netdev_odp *dev, struct dpif_packet **pkts, > dropped++; > continue; > } > - pkt = odp_packet_alloc(dev->pkt_pool); > + pkt = odph_packet_alloc(dev->pkt_pool); > > - if (OVS_UNLIKELY(!odp_packet_is_valid(pkt))) { > + if (OVS_UNLIKELY(!odph_packet_is_valid(pkt))) { > VLOG_WARN_RL(&rl, "Could not allocate packet"); > dropped += cnt -i; > break; > @@ -384,7 +386,7 @@ netdev_odp_send(struct netdev *netdev, struct dpif_packet **pkts, int cnt, > } else { > for (i = 0; i < cnt; i++) { > odp_pkts[i] = pkts[i]->ofpbuf.odp_pkt; > - odp_packet_free(pkts[i]->ofpbuf.odp_ofpbuf); > + odph_packet_free(pkts[i]->ofpbuf.odp_ofpbuf); > } > pkts_ok = cnt; > } > @@ -647,7 +649,7 @@ netdev_odp_rxq_recv(struct netdev_rxq *rxq_, struct dpif_packet **packets, > out_of_memory(); > } > packets[i] = (struct dpif_packet*) odp_buffer_addr(buf); > - ofpbuf_init_odp(&packets[i]->ofpbuf, odp_packet_buf_size(pkt_tbl[i])); > + ofpbuf_init_odp(&packets[i]->ofpbuf, odph_packet_buf_size(pkt_tbl[i])); > packets[i]->ofpbuf.odp_pkt = pkt_tbl[i]; > packets[i]->ofpbuf.odp_ofpbuf = buf; > rx_bytes += odp_packet_get_len(pkt_tbl[i]); > diff --git a/lib/netdev-odp.h b/lib/netdev-odp.h > index a0a2594..f7eaa27 100644 > --- a/lib/netdev-odp.h > +++ b/lib/netdev-odp.h > @@ -7,9 +7,9 @@ > #ifdef ODP_NETDEV > > #include <odp.h> > -#include <helper/odp_eth.h> > -#include <helper/odp_ip.h> > -#include <helper/odp_packet_helper.h> > +#include <helper/odph_eth.h> > +#include <helper/odph_ip.h> > +#include <helper/odph_packet.h> > > /* This function is not exported, we need another way to deal with > creating a packet from an ofpbuf */ > diff --git a/lib/ofpbuf.c b/lib/ofpbuf.c > index 55c59e0..eec7b30 100644 > --- a/lib/ofpbuf.c > +++ b/lib/ofpbuf.c > @@ -153,7 +153,7 @@ ofpbuf_uninit(struct ofpbuf *b) > #endif > } else if (b->source == OFPBUF_ODP) { > #ifdef ODP_NETDEV > - odp_packet_free(b->odp_pkt); > + odph_packet_free(b->odp_pkt); > odp_buffer_free(b->odp_ofpbuf); > #else > ovs_assert(b->source != OFPBUF_ODP); > -- > 1.9.1 >
On 29/10/14 09:58, Ciprian Barbu wrote: > Hello Zoltan, > > Thank you for taking time to look at this. I didn't know you were > going to start working right away, otherwise I would have told you I > made a mistake when I named the branches in my repository, the latest > version is actually ovs_odp_patches (which was previously > ovs_odp_patches_v3) not ovs_odp_patches_v2. Most of the changes in > this patch series are valid, I updated to the renamed > odph_packet_alloc and similar and that's about it, all the other stuff > is needed. I'm going to rename ovs_odp_patches_v2 to > ovs_odp_patches_old and I will remove it in a few days. > > I can still try to apply the patches but if you have more time can you > please send an update based on ovs_odp_patches branch ? I've rebased them to that branch, and sent them in. Zoli
diff --git a/lib/netdev-odp.c b/lib/netdev-odp.c index 785dc06..f979743 100644 --- a/lib/netdev-odp.c +++ b/lib/netdev-odp.c @@ -94,7 +94,7 @@ struct netdev_rxq_odp { void free_odp_buf(struct ofpbuf *b) { - odp_packet_free(b->odp_pkt); + odph_packet_free(b->odp_pkt); odp_buffer_free(b->odp_ofpbuf); } @@ -102,7 +102,6 @@ int odp_init(int argc, char *argv[]) { int result; - int thr_id; if (strcmp(argv[1], "--odp")) return 0; @@ -110,14 +109,17 @@ odp_init(int argc, char *argv[]) argc--; argv++; - result = odp_init_global(); + result = odp_init_global(NULL, NULL); if (result) { ODP_ERR("Error: ODP global init failed\n"); return result; } - thr_id = odp_thread_create(0); - odp_init_local(thr_id); + /* Init this thread */ + if (odp_init_local()) { + ODP_ERR("Error: ODP local init failed.\n"); + exit(EXIT_FAILURE); + } odp_initialized = 1; @@ -128,11 +130,13 @@ static int odp_class_init(void) { void *pool_base; + odp_shm_t shm; int result = 0; /* create packet pool */ - pool_base = odp_shm_reserve("shm_packet_pool", SHM_PKT_POOL_SIZE, - ODP_CACHE_LINE_SIZE); + shm = odp_shm_reserve("shm_packet_pool", SHM_PKT_POOL_SIZE, + ODP_CACHE_LINE_SIZE, 0); + pool_base = odp_shm_addr(shm); if (odp_unlikely(pool_base == NULL)) { ODP_ERR("Error: ODP packet pool mem alloc failed\n"); @@ -153,8 +157,9 @@ odp_class_init(void) odp_buffer_pool_print(pool); /* create ofpbuf pool */ - pool_base = odp_shm_reserve("shm_ofpbuf_pool", SHM_OFPBUF_POOL_SIZE, - ODP_CACHE_LINE_SIZE); + shm = odp_shm_reserve("shm_ofpbuf_pool", SHM_OFPBUF_POOL_SIZE, + ODP_CACHE_LINE_SIZE, 0); + pool_base = odp_shm_addr(shm); if (odp_unlikely(pool_base == NULL)) { ODP_ERR("Error: ODP packet pool mem alloc failed\n"); @@ -175,8 +180,9 @@ odp_class_init(void) odp_buffer_pool_print(ofpbuf_pool); /* create pool for structures */ - pool_base = odp_shm_reserve("shm_struct_pool", SHM_STRUCT_POOL_SIZE, - ODP_CACHE_LINE_SIZE); + shm = odp_shm_reserve("shm_struct_pool", SHM_STRUCT_POOL_SIZE, + ODP_CACHE_LINE_SIZE, 0); + pool_base = odp_shm_addr(shm); if (odp_unlikely(pool_base == NULL)) { ODP_ERR("Error: ODP packet pool mem alloc failed\n"); @@ -222,8 +228,6 @@ netdev_odp_construct(struct netdev *netdev_) { int err = 0; char *odp_if; - odp_pktio_params_t params; - socket_params_t *sock_params = ¶ms.sock_params; struct netdev_odp *netdev = netdev_odp_cast(netdev_); odp_packet_t pkt; @@ -234,9 +238,7 @@ netdev_odp_construct(struct netdev *netdev_) goto out_err; } - sock_params->type = ODP_PKTIO_TYPE_SOCKET_BASIC; - - netdev->pktio = odp_pktio_open(odp_if, pool, ¶ms); + netdev->pktio = odp_pktio_open(odp_if, pool); if (netdev->pktio == ODP_PKTIO_INVALID) { ODP_ERR("Error: odp pktio failed\n"); @@ -245,15 +247,15 @@ netdev_odp_construct(struct netdev *netdev_) } netdev->pkt_pool = pool; - pkt = odp_packet_alloc(netdev->pkt_pool); - if (!odp_packet_is_valid(pkt)) { + pkt = odph_packet_alloc(netdev->pkt_pool); + if (!odph_packet_is_valid(pkt)) { out_of_memory(); goto out_err; } - netdev->max_frame_len = odp_packet_buf_size(pkt); + netdev->max_frame_len = odph_packet_buf_size(pkt); - odp_packet_free(pkt); + odph_packet_free(pkt); ovs_mutex_init(&netdev->mutex); @@ -302,7 +304,7 @@ static int drop_err_pkts(odp_packet_t pkt_tbl[], unsigned len) pkt = pkt_tbl[i]; if (odp_unlikely(odp_packet_error(pkt))) { - odp_packet_free(pkt); /* Drop */ + odph_packet_free(pkt); /* Drop */ pkt_cnt--; } else if (odp_unlikely(i != j++)) { pkt_tbl[j-1] = pkt; @@ -332,9 +334,9 @@ clone_pkts(struct netdev_odp *dev, struct dpif_packet **pkts, dropped++; continue; } - pkt = odp_packet_alloc(dev->pkt_pool); + pkt = odph_packet_alloc(dev->pkt_pool); - if (OVS_UNLIKELY(!odp_packet_is_valid(pkt))) { + if (OVS_UNLIKELY(!odph_packet_is_valid(pkt))) { VLOG_WARN_RL(&rl, "Could not allocate packet"); dropped += cnt -i; break; @@ -384,7 +386,7 @@ netdev_odp_send(struct netdev *netdev, struct dpif_packet **pkts, int cnt, } else { for (i = 0; i < cnt; i++) { odp_pkts[i] = pkts[i]->ofpbuf.odp_pkt; - odp_packet_free(pkts[i]->ofpbuf.odp_ofpbuf); + odph_packet_free(pkts[i]->ofpbuf.odp_ofpbuf); } pkts_ok = cnt; } @@ -647,7 +649,7 @@ netdev_odp_rxq_recv(struct netdev_rxq *rxq_, struct dpif_packet **packets, out_of_memory(); } packets[i] = (struct dpif_packet*) odp_buffer_addr(buf); - ofpbuf_init_odp(&packets[i]->ofpbuf, odp_packet_buf_size(pkt_tbl[i])); + ofpbuf_init_odp(&packets[i]->ofpbuf, odph_packet_buf_size(pkt_tbl[i])); packets[i]->ofpbuf.odp_pkt = pkt_tbl[i]; packets[i]->ofpbuf.odp_ofpbuf = buf; rx_bytes += odp_packet_get_len(pkt_tbl[i]); diff --git a/lib/netdev-odp.h b/lib/netdev-odp.h index a0a2594..f7eaa27 100644 --- a/lib/netdev-odp.h +++ b/lib/netdev-odp.h @@ -7,9 +7,9 @@ #ifdef ODP_NETDEV #include <odp.h> -#include <helper/odp_eth.h> -#include <helper/odp_ip.h> -#include <helper/odp_packet_helper.h> +#include <helper/odph_eth.h> +#include <helper/odph_ip.h> +#include <helper/odph_packet.h> /* This function is not exported, we need another way to deal with creating a packet from an ofpbuf */ diff --git a/lib/ofpbuf.c b/lib/ofpbuf.c index 55c59e0..eec7b30 100644 --- a/lib/ofpbuf.c +++ b/lib/ofpbuf.c @@ -153,7 +153,7 @@ ofpbuf_uninit(struct ofpbuf *b) #endif } else if (b->source == OFPBUF_ODP) { #ifdef ODP_NETDEV - odp_packet_free(b->odp_pkt); + odph_packet_free(b->odp_pkt); odp_buffer_free(b->odp_ofpbuf); #else ovs_assert(b->source != OFPBUF_ODP);