@@ -77,14 +77,6 @@ static int smb_direct_max_receive_size = 1364;
7777
7878static int smb_direct_max_read_write_size = SMBD_DEFAULT_IOSIZE ;
7979
80- static LIST_HEAD (smb_direct_device_list );
81- static DEFINE_RWLOCK (smb_direct_device_lock );
82-
83- struct smb_direct_device {
84- struct ib_device * ib_dev ;
85- struct list_head list ;
86- };
87-
8880static struct smb_direct_listener {
8981 int port ;
9082
@@ -500,48 +492,6 @@ static int smb_direct_listen(struct smb_direct_listener *listener,
500492 return ret ;
501493}
502494
503- static int smb_direct_ib_client_add (struct ib_device * ib_dev )
504- {
505- struct smb_direct_device * smb_dev ;
506-
507- if (!smbdirect_frwr_is_supported (& ib_dev -> attrs ))
508- return 0 ;
509-
510- smb_dev = kzalloc_obj (* smb_dev , KSMBD_DEFAULT_GFP );
511- if (!smb_dev )
512- return - ENOMEM ;
513- smb_dev -> ib_dev = ib_dev ;
514-
515- write_lock (& smb_direct_device_lock );
516- list_add (& smb_dev -> list , & smb_direct_device_list );
517- write_unlock (& smb_direct_device_lock );
518-
519- ksmbd_debug (RDMA , "ib device added: name %s\n" , ib_dev -> name );
520- return 0 ;
521- }
522-
523- static void smb_direct_ib_client_remove (struct ib_device * ib_dev ,
524- void * client_data )
525- {
526- struct smb_direct_device * smb_dev , * tmp ;
527-
528- write_lock (& smb_direct_device_lock );
529- list_for_each_entry_safe (smb_dev , tmp , & smb_direct_device_list , list ) {
530- if (smb_dev -> ib_dev == ib_dev ) {
531- list_del (& smb_dev -> list );
532- kfree (smb_dev );
533- break ;
534- }
535- }
536- write_unlock (& smb_direct_device_lock );
537- }
538-
539- static struct ib_client smb_direct_ib_client = {
540- .name = "ksmbd_smb_direct_ib" ,
541- .add = smb_direct_ib_client_add ,
542- .remove = smb_direct_ib_client_remove ,
543- };
544-
545495int ksmbd_rdma_init (void )
546496{
547497 int ret ;
@@ -550,12 +500,6 @@ int ksmbd_rdma_init(void)
550500 .socket = NULL ,
551501 };
552502
553- ret = ib_register_client (& smb_direct_ib_client );
554- if (ret ) {
555- pr_err ("failed to ib_register_client\n" );
556- return ret ;
557- }
558-
559503 /* When a client is running out of send credits, the credits are
560504 * granted by the server's sending a packet using this queue.
561505 * This avoids the situation that a clients cannot send packets
@@ -598,11 +542,6 @@ int ksmbd_rdma_init(void)
598542
599543void ksmbd_rdma_stop_listening (void )
600544{
601- if (!smb_direct_ib_listener .socket && !smb_direct_iw_listener .socket )
602- return ;
603-
604- ib_unregister_client (& smb_direct_ib_client );
605-
606545 smb_direct_listener_destroy (& smb_direct_ib_listener );
607546 smb_direct_listener_destroy (& smb_direct_iw_listener );
608547}
@@ -615,68 +554,11 @@ void ksmbd_rdma_destroy(void)
615554 }
616555}
617556
618- static bool ksmbd_find_rdma_capable_netdev (struct net_device * netdev )
619- {
620- struct smb_direct_device * smb_dev ;
621- int i ;
622- bool rdma_capable = false;
623-
624- read_lock (& smb_direct_device_lock );
625- list_for_each_entry (smb_dev , & smb_direct_device_list , list ) {
626- for (i = 0 ; i < smb_dev -> ib_dev -> phys_port_cnt ; i ++ ) {
627- struct net_device * ndev ;
628-
629- ndev = ib_device_get_netdev (smb_dev -> ib_dev , i + 1 );
630- if (!ndev )
631- continue ;
632-
633- if (ndev == netdev ) {
634- dev_put (ndev );
635- rdma_capable = true;
636- goto out ;
637- }
638- dev_put (ndev );
639- }
640- }
641- out :
642- read_unlock (& smb_direct_device_lock );
643-
644- if (rdma_capable == false) {
645- struct ib_device * ibdev ;
646-
647- ibdev = ib_device_get_by_netdev (netdev , RDMA_DRIVER_UNKNOWN );
648- if (ibdev ) {
649- rdma_capable = smbdirect_frwr_is_supported (& ibdev -> attrs );
650- ib_device_put (ibdev );
651- }
652- }
653-
654- ksmbd_debug (RDMA , "netdev(%s) rdma capable : %s\n" ,
655- netdev -> name , str_true_false (rdma_capable ));
656-
657- return rdma_capable ;
658- }
659-
660557bool ksmbd_rdma_capable_netdev (struct net_device * netdev )
661558{
662- struct net_device * lower_dev ;
663- struct list_head * iter ;
664-
665- if (ksmbd_find_rdma_capable_netdev (netdev ))
666- return true;
667-
668- /* check if netdev is bridge or VLAN */
669- if (netif_is_bridge_master (netdev ) ||
670- netdev -> priv_flags & IFF_802_1Q_VLAN )
671- netdev_for_each_lower_dev (netdev , lower_dev , iter )
672- if (ksmbd_find_rdma_capable_netdev (lower_dev ))
673- return true;
674-
675- /* check if netdev is IPoIB safely without layer violation */
676- if (netdev -> type == ARPHRD_INFINIBAND )
677- return true;
559+ u8 node_type = smbdirect_netdev_rdma_capable_node_type (netdev );
678560
679- return false ;
561+ return node_type != RDMA_NODE_UNSPECIFIED ;
680562}
681563
682564static const struct ksmbd_transport_ops ksmbd_smb_direct_transport_ops = {
0 commit comments