[dpdk-dev,1/2] net/octeontx: add channel to port id mapping

Message ID 20171128145855.27106-1-pbhagavatula@caviumnetworks.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Pavan Nikhilesh Nov. 28, 2017, 2:58 p.m. UTC
  The channel to port id map is used by event octeontx to map the received
wqe to the respective ethdev port.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
---
 drivers/net/octeontx/octeontx_ethdev.c | 3 +++
 drivers/net/octeontx/octeontx_ethdev.h | 6 ++++++
 2 files changed, 9 insertions(+)
  

Comments

Ferruh Yigit Dec. 8, 2017, 12:41 a.m. UTC | #1
On 11/28/2017 6:58 AM, Pavan Nikhilesh wrote:
> The channel to port id map is used by event octeontx to map the received
> wqe to the respective ethdev port.
> 
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>

<...>

> @@ -52,12 +52,18 @@
>  #define OCTEONTX_VDEV_NR_PORT_ARG		("nr_port")
>  #define OCTEONTX_MAX_NAME_LEN			32
>  
> +#define OCTEONTX_MAX_BGX_PORTS			4
> +#define OCTEONTX_MAX_LMAC_PER_BGX		4
> +
>  static inline struct octeontx_nic *
>  octeontx_pmd_priv(struct rte_eth_dev *dev)
>  {
>  	return dev->data->dev_private;
>  }
>  
> +uint16_t __rte_cache_aligned
> +octeontx_pchan_map[OCTEONTX_MAX_BGX_PORTS][OCTEONTX_MAX_LMAC_PER_BGX];

defining global variable in header is generally not good a idea, is there a
reason why not variable defined in octeontx_ethdev.c and exported here, so that
both octeontx ethdev and eventdev can use it?

btw, is build time dependency between octeontx ethdev and eventdev documented
somewhere?
  
Pavan Nikhilesh Dec. 8, 2017, 11:08 a.m. UTC | #2
On Thu, Dec 07, 2017 at 04:41:04PM -0800, Ferruh Yigit wrote:
> On 11/28/2017 6:58 AM, Pavan Nikhilesh wrote:
> > The channel to port id map is used by event octeontx to map the received
> > wqe to the respective ethdev port.
> >
> > Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
>
> <...>
>
> > @@ -52,12 +52,18 @@
> >  #define OCTEONTX_VDEV_NR_PORT_ARG		("nr_port")
> >  #define OCTEONTX_MAX_NAME_LEN			32
> >
> > +#define OCTEONTX_MAX_BGX_PORTS			4
> > +#define OCTEONTX_MAX_LMAC_PER_BGX		4
> > +
> >  static inline struct octeontx_nic *
> >  octeontx_pmd_priv(struct rte_eth_dev *dev)
> >  {
> >  	return dev->data->dev_private;
> >  }
> >
> > +uint16_t __rte_cache_aligned
> > +octeontx_pchan_map[OCTEONTX_MAX_BGX_PORTS][OCTEONTX_MAX_LMAC_PER_BGX];
>
> defining global variable in header is generally not good a idea, is there a
> reason why not variable defined in octeontx_ethdev.c and exported here, so that
> both octeontx ethdev and eventdev can use it?

The reason extern definition in .h and declaration in .c is not done is that
it would break shared compilation.
The other approach is to do it in  octeontx_mempool area but it wouldnt make
sense.
I could use the mempool approach if it sounds good to you (or) let me know
if any alternate approach comes to your mind.

>
> btw, is build time dependency between octeontx ethdev and eventdev documented
> somewhere?

Currently, there is no build time dependency between event_octeontx and
eth_octeontx i.e everything builds fine with CONFIG_RTE_LIBRTE_OCTEONTX_PMD=n.

Thanks,
Pavan
  
Ferruh Yigit Dec. 8, 2017, 5:39 p.m. UTC | #3
On 12/8/2017 3:08 AM, Pavan Nikhilesh Bhagavatula wrote:
> On Thu, Dec 07, 2017 at 04:41:04PM -0800, Ferruh Yigit wrote:
>> On 11/28/2017 6:58 AM, Pavan Nikhilesh wrote:
>>> The channel to port id map is used by event octeontx to map the received
>>> wqe to the respective ethdev port.
>>>
>>> Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
>>
>> <...>
>>
>>> @@ -52,12 +52,18 @@
>>>  #define OCTEONTX_VDEV_NR_PORT_ARG		("nr_port")
>>>  #define OCTEONTX_MAX_NAME_LEN			32
>>>
>>> +#define OCTEONTX_MAX_BGX_PORTS			4
>>> +#define OCTEONTX_MAX_LMAC_PER_BGX		4
>>> +
>>>  static inline struct octeontx_nic *
>>>  octeontx_pmd_priv(struct rte_eth_dev *dev)
>>>  {
>>>  	return dev->data->dev_private;
>>>  }
>>>
>>> +uint16_t __rte_cache_aligned
>>> +octeontx_pchan_map[OCTEONTX_MAX_BGX_PORTS][OCTEONTX_MAX_LMAC_PER_BGX];
>>
>> defining global variable in header is generally not good a idea, is there a
>> reason why not variable defined in octeontx_ethdev.c and exported here, so that
>> both octeontx ethdev and eventdev can use it?
> 
> The reason extern definition in .h and declaration in .c is not done is that
> it would break shared compilation.

This should work, you can put object into .so and access from application and/or
other shared libraries. I did a quick test, and seems working, is there anything
I am missing.

> The other approach is to do it in  octeontx_mempool area but it wouldnt make
> sense.
> I could use the mempool approach if it sounds good to you (or) let me know
> if any alternate approach comes to your mind.
> 
>>
>> btw, is build time dependency between octeontx ethdev and eventdev documented
>> somewhere?
> 
> Currently, there is no build time dependency between event_octeontx and
> eth_octeontx i.e everything builds fine with CONFIG_RTE_LIBRTE_OCTEONTX_PMD=n.

octeontx eventdev is using a variable from octeontx ethdev header, how can be
there is no build time dependency?

> 
> Thanks,
> Pavan
>
  
Pavan Nikhilesh Dec. 9, 2017, 9:25 a.m. UTC | #4
On Fri, Dec 08, 2017 at 09:39:00AM -0800, Ferruh Yigit wrote:
> On 12/8/2017 3:08 AM, Pavan Nikhilesh Bhagavatula wrote:
> > On Thu, Dec 07, 2017 at 04:41:04PM -0800, Ferruh Yigit wrote:
> >> On 11/28/2017 6:58 AM, Pavan Nikhilesh wrote:
> >>> The channel to port id map is used by event octeontx to map the received
> >>> wqe to the respective ethdev port.
> >>>
> >>> Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> >>
> >> <...>
> >>
> >>> @@ -52,12 +52,18 @@
> >>>  #define OCTEONTX_VDEV_NR_PORT_ARG		("nr_port")
> >>>  #define OCTEONTX_MAX_NAME_LEN			32
> >>>
> >>> +#define OCTEONTX_MAX_BGX_PORTS			4
> >>> +#define OCTEONTX_MAX_LMAC_PER_BGX		4
> >>> +
> >>>  static inline struct octeontx_nic *
> >>>  octeontx_pmd_priv(struct rte_eth_dev *dev)
> >>>  {
> >>>  	return dev->data->dev_private;
> >>>  }
> >>>
> >>> +uint16_t __rte_cache_aligned
> >>> +octeontx_pchan_map[OCTEONTX_MAX_BGX_PORTS][OCTEONTX_MAX_LMAC_PER_BGX];
> >>
> >> defining global variable in header is generally not good a idea, is there a
> >> reason why not variable defined in octeontx_ethdev.c and exported here, so that
> >> both octeontx ethdev and eventdev can use it?
> >
> > The reason extern definition in .h and declaration in .c is not done is that
> > it would break shared compilation.
>
> This should work, you can put object into .so and access from application and/or
> other shared libraries. I did a quick test, and seems working, is there anything
> I am missing.
>
> > The other approach is to do it in  octeontx_mempool area but it wouldnt make
> > sense.
> > I could use the mempool approach if it sounds good to you (or) let me know
> > if any alternate approach comes to your mind.
> >
> >>
> >> btw, is build time dependency between octeontx ethdev and eventdev documented
> >> somewhere?
> >
> > Currently, there is no build time dependency between event_octeontx and
> > eth_octeontx i.e everything builds fine with CONFIG_RTE_LIBRTE_OCTEONTX_PMD=n.
>
> octeontx eventdev is using a variable from octeontx ethdev header, how can be
> there is no build time dependency?
>
Hi Ferruh,

I misread the order in which thing are built. I will send out a v2 with the
suggested changes soon.

Thanks,
Pavan

> >
> > Thanks,
> > Pavan
> >
>
  

Patch

diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c
index bd24ec330..8e251786b 100644
--- a/drivers/net/octeontx/octeontx_ethdev.c
+++ b/drivers/net/octeontx/octeontx_ethdev.c
@@ -1133,6 +1133,9 @@  octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev,
 				nic->num_tx_queues);
 	PMD_INIT_LOG(DEBUG, "speed %d mtu %d", nic->speed, nic->mtu);
 
+	octeontx_pchan_map[(nic->base_ochan >> 8) & 0x7]
+		[(nic->base_ochan >> 4) & 0xF] = data->port_id;
+
 	return data->port_id;
 
 err:
diff --git a/drivers/net/octeontx/octeontx_ethdev.h b/drivers/net/octeontx/octeontx_ethdev.h
index c47d4c6d3..0cff13611 100644
--- a/drivers/net/octeontx/octeontx_ethdev.h
+++ b/drivers/net/octeontx/octeontx_ethdev.h
@@ -52,12 +52,18 @@ 
 #define OCTEONTX_VDEV_NR_PORT_ARG		("nr_port")
 #define OCTEONTX_MAX_NAME_LEN			32
 
+#define OCTEONTX_MAX_BGX_PORTS			4
+#define OCTEONTX_MAX_LMAC_PER_BGX		4
+
 static inline struct octeontx_nic *
 octeontx_pmd_priv(struct rte_eth_dev *dev)
 {
 	return dev->data->dev_private;
 }
 
+uint16_t __rte_cache_aligned
+octeontx_pchan_map[OCTEONTX_MAX_BGX_PORTS][OCTEONTX_MAX_LMAC_PER_BGX];
+
 /* Octeontx ethdev nic */
 struct octeontx_nic {
 	struct rte_eth_dev *dev;