@@ -169,7 +169,8 @@ static int dpif_linux_init(void);
169169static void open_dpif (const struct dpif_linux_dp * , struct dpif * * );
170170static bool dpif_linux_nln_parse (struct ofpbuf * , void * );
171171static void dpif_linux_port_changed (const void * vport , void * dpif );
172- static uint32_t dpif_linux_port_get_pid (const struct dpif * , uint32_t port_no );
172+ static uint32_t dpif_linux_port_get_pid (const struct dpif * ,
173+ odp_port_t port_no );
173174
174175static void dpif_linux_vport_to_ofpbuf (const struct dpif_linux_vport * ,
175176 struct ofpbuf * );
@@ -261,7 +262,7 @@ open_dpif(const struct dpif_linux_dp *dp, struct dpif **dpifp)
261262static void
262263destroy_channels (struct dpif_linux * dpif )
263264{
264- int i ;
265+ unsigned int i ;
265266
266267 if (dpif -> epoll_fd < 0 ) {
267268 return ;
@@ -280,7 +281,7 @@ destroy_channels(struct dpif_linux *dpif)
280281 dpif_linux_vport_init (& vport_request );
281282 vport_request .cmd = OVS_VPORT_CMD_SET ;
282283 vport_request .dp_ifindex = dpif -> dp_ifindex ;
283- vport_request .port_no = i ;
284+ vport_request .port_no = u32_to_odp ( i ) ;
284285 vport_request .upcall_pid = & upcall_pid ;
285286 dpif_linux_vport_transact (& vport_request , NULL , NULL );
286287
@@ -300,19 +301,20 @@ destroy_channels(struct dpif_linux *dpif)
300301}
301302
302303static int
303- add_channel (struct dpif_linux * dpif , uint32_t port_no , struct nl_sock * sock )
304+ add_channel (struct dpif_linux * dpif , odp_port_t port_no , struct nl_sock * sock )
304305{
305306 struct epoll_event event ;
307+ uint32_t port_idx = odp_to_u32 (port_no );
306308
307309 if (dpif -> epoll_fd < 0 ) {
308310 return 0 ;
309311 }
310312
311313 /* We assume that the datapath densely chooses port numbers, which
312314 * can therefore be used as an index into an array of channels. */
313- if (port_no >= dpif -> uc_array_size ) {
314- int new_size = port_no + 1 ;
315- int i ;
315+ if (port_idx >= dpif -> uc_array_size ) {
316+ uint32_t new_size = port_idx + 1 ;
317+ uint32_t i ;
316318
317319 if (new_size > MAX_PORTS ) {
318320 VLOG_WARN_RL (& error_rl , "%s: datapath port %" PRIu32 " too big" ,
@@ -333,29 +335,30 @@ add_channel(struct dpif_linux *dpif, uint32_t port_no, struct nl_sock *sock)
333335
334336 memset (& event , 0 , sizeof event );
335337 event .events = EPOLLIN ;
336- event .data .u32 = port_no ;
338+ event .data .u32 = port_idx ;
337339 if (epoll_ctl (dpif -> epoll_fd , EPOLL_CTL_ADD , nl_sock_fd (sock ),
338340 & event ) < 0 ) {
339341 return errno ;
340342 }
341343
342- nl_sock_destroy (dpif -> channels [port_no ].sock );
343- dpif -> channels [port_no ].sock = sock ;
344- dpif -> channels [port_no ].last_poll = LLONG_MIN ;
344+ nl_sock_destroy (dpif -> channels [port_idx ].sock );
345+ dpif -> channels [port_idx ].sock = sock ;
346+ dpif -> channels [port_idx ].last_poll = LLONG_MIN ;
345347
346348 return 0 ;
347349}
348350
349351static void
350- del_channel (struct dpif_linux * dpif , uint32_t port_no )
352+ del_channel (struct dpif_linux * dpif , odp_port_t port_no )
351353{
352354 struct dpif_channel * ch ;
355+ uint32_t port_idx = odp_to_u32 (port_no );
353356
354- if (dpif -> epoll_fd < 0 || port_no >= dpif -> uc_array_size ) {
357+ if (dpif -> epoll_fd < 0 || port_idx >= dpif -> uc_array_size ) {
355358 return ;
356359 }
357360
358- ch = & dpif -> channels [port_no ];
361+ ch = & dpif -> channels [port_idx ];
359362 if (!ch -> sock ) {
360363 return ;
361364 }
@@ -482,7 +485,7 @@ netdev_to_ovs_vport_type(const struct netdev *netdev)
482485
483486static int
484487dpif_linux_port_add (struct dpif * dpif_ , struct netdev * netdev ,
485- uint32_t * port_nop )
488+ odp_port_t * port_nop )
486489{
487490 struct dpif_linux * dpif = dpif_linux_cast (dpif_ );
488491 const struct netdev_tunnel_config * tnl_cfg ;
@@ -541,7 +544,7 @@ dpif_linux_port_add(struct dpif *dpif_, struct netdev *netdev,
541544 VLOG_DBG ("%s: assigning port %" PRIu32 " to netlink pid %" PRIu32 ,
542545 dpif_name (dpif_ ), reply .port_no , upcall_pid );
543546 } else {
544- if (error == EBUSY && * port_nop != UINT32_MAX ) {
547+ if (error == EBUSY && * port_nop != ODPP_NONE ) {
545548 VLOG_INFO ("%s: requested port %" PRIu32 " is in use" ,
546549 dpif_name (dpif_ ), * port_nop );
547550 }
@@ -573,7 +576,7 @@ dpif_linux_port_add(struct dpif *dpif_, struct netdev *netdev,
573576}
574577
575578static int
576- dpif_linux_port_del (struct dpif * dpif_ , uint32_t port_no )
579+ dpif_linux_port_del (struct dpif * dpif_ , odp_port_t port_no )
577580{
578581 struct dpif_linux * dpif = dpif_linux_cast (dpif_ );
579582 struct dpif_linux_vport vport ;
@@ -591,7 +594,7 @@ dpif_linux_port_del(struct dpif *dpif_, uint32_t port_no)
591594}
592595
593596static int
594- dpif_linux_port_query__ (const struct dpif * dpif , uint32_t port_no ,
597+ dpif_linux_port_query__ (const struct dpif * dpif , odp_port_t port_no ,
595598 const char * port_name , struct dpif_port * dpif_port )
596599{
597600 struct dpif_linux_vport request ;
@@ -622,7 +625,7 @@ dpif_linux_port_query__(const struct dpif *dpif, uint32_t port_no,
622625}
623626
624627static int
625- dpif_linux_port_query_by_number (const struct dpif * dpif , uint32_t port_no ,
628+ dpif_linux_port_query_by_number (const struct dpif * dpif , odp_port_t port_no ,
626629 struct dpif_port * dpif_port )
627630{
628631 return dpif_linux_port_query__ (dpif , port_no , NULL , dpif_port );
@@ -635,23 +638,24 @@ dpif_linux_port_query_by_name(const struct dpif *dpif, const char *devname,
635638 return dpif_linux_port_query__ (dpif , 0 , devname , dpif_port );
636639}
637640
638- static int
641+ static odp_port_t
639642dpif_linux_get_max_ports (const struct dpif * dpif OVS_UNUSED )
640643{
641- return MAX_PORTS ;
644+ return u32_to_odp ( MAX_PORTS ) ;
642645}
643646
644647static uint32_t
645- dpif_linux_port_get_pid (const struct dpif * dpif_ , uint32_t port_no )
648+ dpif_linux_port_get_pid (const struct dpif * dpif_ , odp_port_t port_no )
646649{
647650 struct dpif_linux * dpif = dpif_linux_cast (dpif_ );
651+ uint32_t port_idx = odp_to_u32 (port_no );
648652
649653 if (dpif -> epoll_fd < 0 ) {
650654 return 0 ;
651655 } else {
652- /* The UINT32_MAX "reserved" port number uses the "ovs-system"'s
656+ /* The ODPP_NONE "reserved" port number uses the "ovs-system"'s
653657 * channel, since it is not heavily loaded. */
654- int idx = ( port_no >= dpif -> uc_array_size ) ? 0 : port_no ;
658+ uint32_t idx = port_idx >= dpif -> uc_array_size ? 0 : port_idx ;
655659 return nl_sock_pid (dpif -> channels [idx ].sock );
656660 }
657661}
@@ -1562,7 +1566,7 @@ dpif_linux_vport_from_ofpbuf(struct dpif_linux_vport *vport,
15621566
15631567 vport -> cmd = genl -> cmd ;
15641568 vport -> dp_ifindex = ovs_header -> dp_ifindex ;
1565- vport -> port_no = nl_attr_get_u32 (a [OVS_VPORT_ATTR_PORT_NO ]);
1569+ vport -> port_no = nl_attr_get_odp_port (a [OVS_VPORT_ATTR_PORT_NO ]);
15661570 vport -> type = nl_attr_get_u32 (a [OVS_VPORT_ATTR_TYPE ]);
15671571 vport -> name = nl_attr_get_string (a [OVS_VPORT_ATTR_NAME ]);
15681572 if (a [OVS_VPORT_ATTR_UPCALL_PID ]) {
@@ -1592,8 +1596,8 @@ dpif_linux_vport_to_ofpbuf(const struct dpif_linux_vport *vport,
15921596 ovs_header = ofpbuf_put_uninit (buf , sizeof * ovs_header );
15931597 ovs_header -> dp_ifindex = vport -> dp_ifindex ;
15941598
1595- if (vport -> port_no != UINT32_MAX ) {
1596- nl_msg_put_u32 (buf , OVS_VPORT_ATTR_PORT_NO , vport -> port_no );
1599+ if (vport -> port_no != ODPP_NONE ) {
1600+ nl_msg_put_odp_port (buf , OVS_VPORT_ATTR_PORT_NO , vport -> port_no );
15971601 }
15981602
15991603 if (vport -> type != OVS_VPORT_TYPE_UNSPEC ) {
@@ -1624,7 +1628,7 @@ void
16241628dpif_linux_vport_init (struct dpif_linux_vport * vport )
16251629{
16261630 memset (vport , 0 , sizeof * vport );
1627- vport -> port_no = UINT32_MAX ;
1631+ vport -> port_no = ODPP_NONE ;
16281632}
16291633
16301634/* Executes 'request' in the kernel datapath. If the command fails, returns a
0 commit comments