> -----Original Message----- > From: Pattan, Reshma > Sent: Friday, May 27, 2016 3:55 PM > To: Ananyev, Konstantin; dev at dpdk.org > Cc: Pattan, Reshma > Subject: RE: [dpdk-dev] [PATCH v4 5/9] lib/librte_pdump: add new library for > packet capturing support > > > > > -----Original Message----- > > From: Ananyev, Konstantin > > Sent: Friday, May 27, 2016 2:39 PM > > To: Pattan, Reshma <reshma.pattan at intel.com>; dev at dpdk.org > > Cc: Pattan, Reshma <reshma.pattan at intel.com> > > Subject: RE: [dpdk-dev] [PATCH v4 5/9] lib/librte_pdump: add new library for > > packet capturing support > > > > Hi Reshma, > > > > +static int > > > +pdump_regitser_callbacks(uint32_t dir, uint16_t end_q, > > > + uint8_t port, uint16_t queue, > > > + struct rte_ring *ring, struct rte_mempool *mp, > > > + uint16_t operation) > > > +{ > > > + > > > + uint16_t qid; > > > + struct pdump_rxtx_cbs *cbs = NULL; > > > + > > > + qid = (queue == RTE_PDUMP_ALL_QUEUES) ? 0 : queue; > > > + for (; qid < end_q; qid++) { > > > + if ((dir & RTE_PDUMP_FLAG_RX) != 0) > > > + cbs = &rx_cbs[port][qid]; > > > + if ((dir & RTE_PDUMP_FLAG_TX) != 0) > > > + cbs = &tx_cbs[port][qid]; > > > > In case you have dir == (RTE_PDUMP_FLAG_RX | RTE_PDUMP_FLAG_TX) you'll > > overwrite your rx_cbs pointer with tx_cbs pointer. > > I suppose you need 2 local vars: cbs_rx and cbs_tx here. > > Again probably worth to have 2 helper functions: > > pdump_regitser_rx_callback() and pdump_regitser_tx_callback() and call them > > from that one. > > Or you'll never invoke that function with dir ==(RTE_PDUMP_FLAG_RX | > > RTE_PDUMP_FLAG_TX)? > > If so, it porbably worth to put it into comments, though if it would be me, > > I still > > think it would be good to split it in a way I mentioned above. > > > > Yes, I never invoke the function with dir ==(RTE_PDUMP_FLAG_RX | > RTE_PDUMP_FLAG_TX).
Ok, then at least probably comment it somehow. Though I still think 2 different variables (and might be functions) would be better. > > > > + > > > + dir = p->dir; > > > + operation = p->op; > > > + if (operation == ENABLE) { > > > + if (p->data.en_v1.is_pci_or_name == true) { > > > + /* check if device is pci address or name */ > > > + if (pdump_get_dombdf(p->data.en_v1.device, domBDF) > > == 0) > > > + ret = rte_eth_dev_get_port_by_name(domBDF, > > &port); > > > + else > > > + ret = rte_eth_dev_get_port_by_name(p- > > >data.en_v1.device, > > > + > > &port); > > > > > > Why we can't force client to have device name in predefined format? > > Then you woudn't need that name conversion here. > > You mean I should do the conversion pdump_get_dombdf() in client and then > pass that value to server? Yes. > > > > > > + if (ret < 0) { > > > + RTE_LOG(ERR, PDUMP, > > > + "failed to get potid for device > > id=%s\n", > > > + p->data.en_v1.device); > > > + return -EINVAL; > > > + } > > > + } else /* if device is port id */ > > > + port = atoi(p->data.en_v1.device); > > > > Hmm, again why not make server to accept requests only by device id? > > Then it would be client responsibility to do port to device id, and you can > > get rid > > of some duplicated code here. > > If client is secondary process then the same port id on primary and > secondary processes might be mapping to different devices right? Yes. > If so I cannot do port id to device name conversion in client. Ok, but the client can do either port_enable/disable by client port id, or (if that device is not mapped on the client) by device_id. Konstantin > > Thanks, > Reshma