License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 17:07:57 +03:00
// SPDX-License-Identifier: GPL-2.0
2017-01-09 18:55:15 +03:00
/*
* Shared Memory Communications over RDMA ( SMC - R ) and RoCE
*
* Generic netlink support functions to configure an SMC - R PNET table
*
* Copyright IBM Corp . 2016
*
* Author ( s ) : Thomas Richter < tmricht @ linux . vnet . ibm . com >
*/
# include <linux/module.h>
# include <linux/list.h>
# include <linux/ctype.h>
# include <net/netlink.h>
# include <net/genetlink.h>
# include <uapi/linux/if.h>
# include <uapi/linux/smc.h>
# include <rdma/ib_verbs.h>
2019-02-21 15:01:02 +03:00
# include <net/netns/generic.h>
# include "smc_netns.h"
2017-01-09 18:55:15 +03:00
# include "smc_pnet.h"
# include "smc_ib.h"
2018-06-28 20:05:08 +03:00
# include "smc_ism.h"
2019-04-12 13:57:26 +03:00
# include "smc_core.h"
2017-01-09 18:55:15 +03:00
2019-02-21 15:01:00 +03:00
# define SMC_ASCII_BLANK 32
static struct net_device * pnet_find_base_ndev ( struct net_device * ndev ) ;
2017-01-09 18:55:15 +03:00
static struct nla_policy smc_pnet_policy [ SMC_PNETID_MAX + 1 ] = {
[ SMC_PNETID_NAME ] = {
. type = NLA_NUL_STRING ,
2019-01-30 20:51:01 +03:00
. len = SMC_MAX_PNETID_LEN
2017-01-09 18:55:15 +03:00
} ,
[ SMC_PNETID_ETHNAME ] = {
. type = NLA_NUL_STRING ,
. len = IFNAMSIZ - 1
} ,
[ SMC_PNETID_IBNAME ] = {
. type = NLA_NUL_STRING ,
. len = IB_DEVICE_NAME_MAX - 1
} ,
[ SMC_PNETID_IBPORT ] = { . type = NLA_U8 }
} ;
static struct genl_family smc_pnet_nl_family ;
/**
2019-02-21 15:01:00 +03:00
* struct smc_user_pnetentry - pnet identifier name entry for / from user
2017-01-09 18:55:15 +03:00
* @ list : List node .
* @ pnet_name : Pnet identifier name
* @ ndev : pointer to network device .
* @ smcibdev : Pointer to IB device .
2019-02-21 15:01:00 +03:00
* @ ib_port : Port of IB device .
2019-02-21 15:01:01 +03:00
* @ smcd_dev : Pointer to smcd device .
2017-01-09 18:55:15 +03:00
*/
2019-02-21 15:01:00 +03:00
struct smc_user_pnetentry {
2017-01-09 18:55:15 +03:00
struct list_head list ;
2018-06-28 20:05:05 +03:00
char pnet_name [ SMC_MAX_PNETID_LEN + 1 ] ;
2017-01-09 18:55:15 +03:00
struct net_device * ndev ;
struct smc_ib_device * smcibdev ;
u8 ib_port ;
2019-02-21 15:01:01 +03:00
struct smcd_dev * smcd_dev ;
2017-01-09 18:55:15 +03:00
} ;
2019-02-21 15:01:00 +03:00
/* pnet entry stored in pnet table */
struct smc_pnetentry {
struct list_head list ;
char pnet_name [ SMC_MAX_PNETID_LEN + 1 ] ;
struct net_device * ndev ;
} ;
2017-01-09 18:55:15 +03:00
2019-02-21 15:01:00 +03:00
/* Check if two given pnetids match */
static bool smc_pnet_match ( u8 * pnetid1 , u8 * pnetid2 )
2017-01-09 18:55:15 +03:00
{
2019-02-21 15:01:00 +03:00
int i ;
2017-01-09 18:55:15 +03:00
2019-02-21 15:01:00 +03:00
for ( i = 0 ; i < SMC_MAX_PNETID_LEN ; i + + ) {
if ( ( pnetid1 [ i ] = = 0 | | pnetid1 [ i ] = = SMC_ASCII_BLANK ) & &
( pnetid2 [ i ] = = 0 | | pnetid2 [ i ] = = SMC_ASCII_BLANK ) )
2017-01-09 18:55:15 +03:00
break ;
2019-02-21 15:01:00 +03:00
if ( pnetid1 [ i ] ! = pnetid2 [ i ] )
return false ;
2017-01-09 18:55:15 +03:00
}
2019-02-21 15:01:00 +03:00
return true ;
2017-01-09 18:55:15 +03:00
}
/* Remove a pnetid from the pnet table.
*/
2019-02-21 15:01:02 +03:00
static int smc_pnet_remove_by_pnetid ( struct net * net , char * pnet_name )
2017-01-09 18:55:15 +03:00
{
struct smc_pnetentry * pnetelem , * tmp_pe ;
2019-02-21 15:01:02 +03:00
struct smc_pnettable * pnettable ;
2019-02-21 15:01:00 +03:00
struct smc_ib_device * ibdev ;
2019-02-21 15:01:01 +03:00
struct smcd_dev * smcd_dev ;
2019-02-21 15:01:02 +03:00
struct smc_net * sn ;
2017-01-09 18:55:15 +03:00
int rc = - ENOENT ;
2019-02-21 15:01:00 +03:00
int ibport ;
2017-01-09 18:55:15 +03:00
2019-02-21 15:01:02 +03:00
/* get pnettable for namespace */
sn = net_generic ( net , smc_net_id ) ;
pnettable = & sn - > pnettable ;
2019-02-21 15:01:00 +03:00
/* remove netdevices */
2019-02-21 15:01:02 +03:00
write_lock ( & pnettable - > lock ) ;
list_for_each_entry_safe ( pnetelem , tmp_pe , & pnettable - > pnetlist ,
2017-01-09 18:55:15 +03:00
list ) {
2019-02-21 15:01:00 +03:00
if ( ! pnet_name | |
smc_pnet_match ( pnetelem - > pnet_name , pnet_name ) ) {
2017-01-09 18:55:15 +03:00
list_del ( & pnetelem - > list ) ;
dev_put ( pnetelem - > ndev ) ;
kfree ( pnetelem ) ;
rc = 0 ;
}
}
2019-02-21 15:01:02 +03:00
write_unlock ( & pnettable - > lock ) ;
/* if this is not the initial namespace, stop here */
if ( net ! = & init_net )
return rc ;
2019-02-21 15:01:00 +03:00
/* remove ib devices */
spin_lock ( & smc_ib_devices . lock ) ;
list_for_each_entry ( ibdev , & smc_ib_devices . list , list ) {
for ( ibport = 0 ; ibport < SMC_MAX_PORTS ; ibport + + ) {
if ( ibdev - > pnetid_by_user [ ibport ] & &
( ! pnet_name | |
smc_pnet_match ( pnet_name ,
ibdev - > pnetid [ ibport ] ) ) ) {
memset ( ibdev - > pnetid [ ibport ] , 0 ,
SMC_MAX_PNETID_LEN ) ;
ibdev - > pnetid_by_user [ ibport ] = false ;
rc = 0 ;
}
}
}
spin_unlock ( & smc_ib_devices . lock ) ;
2019-02-21 15:01:01 +03:00
/* remove smcd devices */
spin_lock ( & smcd_dev_list . lock ) ;
list_for_each_entry ( smcd_dev , & smcd_dev_list . list , list ) {
if ( smcd_dev - > pnetid_by_user & &
( ! pnet_name | |
smc_pnet_match ( pnet_name , smcd_dev - > pnetid ) ) ) {
memset ( smcd_dev - > pnetid , 0 , SMC_MAX_PNETID_LEN ) ;
smcd_dev - > pnetid_by_user = false ;
rc = 0 ;
}
}
spin_unlock ( & smcd_dev_list . lock ) ;
2017-01-09 18:55:15 +03:00
return rc ;
}
/* Remove a pnet entry mentioning a given network device from the pnet table.
*/
static int smc_pnet_remove_by_ndev ( struct net_device * ndev )
{
struct smc_pnetentry * pnetelem , * tmp_pe ;
2019-02-21 15:01:02 +03:00
struct smc_pnettable * pnettable ;
struct net * net = dev_net ( ndev ) ;
struct smc_net * sn ;
2017-01-09 18:55:15 +03:00
int rc = - ENOENT ;
2019-02-21 15:01:02 +03:00
/* get pnettable for namespace */
sn = net_generic ( net , smc_net_id ) ;
pnettable = & sn - > pnettable ;
write_lock ( & pnettable - > lock ) ;
list_for_each_entry_safe ( pnetelem , tmp_pe , & pnettable - > pnetlist , list ) {
2017-01-09 18:55:15 +03:00
if ( pnetelem - > ndev = = ndev ) {
list_del ( & pnetelem - > list ) ;
dev_put ( pnetelem - > ndev ) ;
kfree ( pnetelem ) ;
rc = 0 ;
break ;
}
}
2019-02-21 15:01:02 +03:00
write_unlock ( & pnettable - > lock ) ;
2017-01-09 18:55:15 +03:00
return rc ;
}
2019-02-21 15:01:00 +03:00
/* Append a pnetid to the end of the pnet table if not already on this list.
2017-01-09 18:55:15 +03:00
*/
2019-02-21 15:01:02 +03:00
static int smc_pnet_enter ( struct smc_pnettable * pnettable ,
struct smc_user_pnetentry * new_pnetelem )
2017-01-09 18:55:15 +03:00
{
2019-02-21 15:01:00 +03:00
u8 pnet_null [ SMC_MAX_PNETID_LEN ] = { 0 } ;
u8 ndev_pnetid [ SMC_MAX_PNETID_LEN ] ;
struct smc_pnetentry * tmp_pnetelem ;
struct smc_pnetentry * pnetelem ;
2019-02-21 15:01:01 +03:00
bool new_smcddev = false ;
2019-02-21 15:01:00 +03:00
struct net_device * ndev ;
bool new_netdev = true ;
bool new_ibdev = false ;
if ( new_pnetelem - > smcibdev ) {
struct smc_ib_device * ib_dev = new_pnetelem - > smcibdev ;
int ib_port = new_pnetelem - > ib_port ;
spin_lock ( & smc_ib_devices . lock ) ;
if ( smc_pnet_match ( ib_dev - > pnetid [ ib_port - 1 ] , pnet_null ) ) {
memcpy ( ib_dev - > pnetid [ ib_port - 1 ] ,
new_pnetelem - > pnet_name , SMC_MAX_PNETID_LEN ) ;
ib_dev - > pnetid_by_user [ ib_port - 1 ] = true ;
new_ibdev = true ;
2017-01-09 18:55:15 +03:00
}
2019-02-21 15:01:00 +03:00
spin_unlock ( & smc_ib_devices . lock ) ;
2017-01-09 18:55:15 +03:00
}
2019-02-21 15:01:01 +03:00
if ( new_pnetelem - > smcd_dev ) {
struct smcd_dev * smcd_dev = new_pnetelem - > smcd_dev ;
spin_lock ( & smcd_dev_list . lock ) ;
if ( smc_pnet_match ( smcd_dev - > pnetid , pnet_null ) ) {
memcpy ( smcd_dev - > pnetid , new_pnetelem - > pnet_name ,
SMC_MAX_PNETID_LEN ) ;
smcd_dev - > pnetid_by_user = true ;
new_smcddev = true ;
}
spin_unlock ( & smcd_dev_list . lock ) ;
}
2017-01-09 18:55:15 +03:00
2019-02-21 15:01:00 +03:00
if ( ! new_pnetelem - > ndev )
2019-02-21 15:01:01 +03:00
return ( new_ibdev | | new_smcddev ) ? 0 : - EEXIST ;
2019-02-21 15:01:00 +03:00
/* check if (base) netdev already has a pnetid. If there is one, we do
* not want to add a pnet table entry
*/
ndev = pnet_find_base_ndev ( new_pnetelem - > ndev ) ;
if ( ! smc_pnetid_by_dev_port ( ndev - > dev . parent , ndev - > dev_port ,
ndev_pnetid ) )
2019-02-21 15:01:01 +03:00
return ( new_ibdev | | new_smcddev ) ? 0 : - EEXIST ;
2019-02-21 15:01:00 +03:00
/* add a new netdev entry to the pnet table if there isn't one */
tmp_pnetelem = kzalloc ( sizeof ( * pnetelem ) , GFP_KERNEL ) ;
if ( ! tmp_pnetelem )
return - ENOMEM ;
memcpy ( tmp_pnetelem - > pnet_name , new_pnetelem - > pnet_name ,
SMC_MAX_PNETID_LEN ) ;
tmp_pnetelem - > ndev = new_pnetelem - > ndev ;
2017-01-09 18:55:15 +03:00
2019-02-21 15:01:02 +03:00
write_lock ( & pnettable - > lock ) ;
list_for_each_entry ( pnetelem , & pnettable - > pnetlist , list ) {
2019-02-21 15:01:00 +03:00
if ( pnetelem - > ndev = = new_pnetelem - > ndev )
new_netdev = false ;
2017-01-09 18:55:15 +03:00
}
2019-02-21 15:01:00 +03:00
if ( new_netdev ) {
dev_hold ( tmp_pnetelem - > ndev ) ;
2019-02-21 15:01:02 +03:00
list_add_tail ( & tmp_pnetelem - > list , & pnettable - > pnetlist ) ;
write_unlock ( & pnettable - > lock ) ;
2019-02-21 15:01:00 +03:00
} else {
2019-02-21 15:01:02 +03:00
write_unlock ( & pnettable - > lock ) ;
2019-02-21 15:01:00 +03:00
kfree ( tmp_pnetelem ) ;
}
2019-02-21 15:01:01 +03:00
return ( new_netdev | | new_ibdev | | new_smcddev ) ? 0 : - EEXIST ;
2017-01-09 18:55:15 +03:00
}
/* The limit for pnetid is 16 characters.
* Valid characters should be ( single - byte character set ) a - z , A - Z , 0 - 9.
* Lower case letters are converted to upper case .
* Interior blanks should not be used .
*/
static bool smc_pnetid_valid ( const char * pnet_name , char * pnetid )
{
char * bf = skip_spaces ( pnet_name ) ;
size_t len = strlen ( bf ) ;
char * end = bf + len ;
if ( ! len )
return false ;
while ( - - end > = bf & & isspace ( * end ) )
;
2018-06-28 20:05:05 +03:00
if ( end - bf > = SMC_MAX_PNETID_LEN )
2017-01-09 18:55:15 +03:00
return false ;
while ( bf < = end ) {
if ( ! isalnum ( * bf ) )
return false ;
* pnetid + + = islower ( * bf ) ? toupper ( * bf ) : * bf ;
bf + + ;
}
* pnetid = ' \0 ' ;
return true ;
}
/* Find an infiniband device by a given name. The device might not exist. */
2017-04-10 15:57:57 +03:00
static struct smc_ib_device * smc_pnet_find_ib ( char * ib_name )
2017-01-09 18:55:15 +03:00
{
struct smc_ib_device * ibdev ;
spin_lock ( & smc_ib_devices . lock ) ;
list_for_each_entry ( ibdev , & smc_ib_devices . list , list ) {
if ( ! strncmp ( ibdev - > ibdev - > name , ib_name ,
2019-02-21 15:01:03 +03:00
sizeof ( ibdev - > ibdev - > name ) ) | |
! strncmp ( dev_name ( ibdev - > ibdev - > dev . parent ) , ib_name ,
IB_DEVICE_NAME_MAX - 1 ) ) {
2017-01-09 18:55:15 +03:00
goto out ;
}
}
ibdev = NULL ;
out :
spin_unlock ( & smc_ib_devices . lock ) ;
return ibdev ;
}
2019-02-21 15:01:01 +03:00
/* Find an smcd device by a given name. The device might not exist. */
static struct smcd_dev * smc_pnet_find_smcd ( char * smcd_name )
{
struct smcd_dev * smcd_dev ;
spin_lock ( & smcd_dev_list . lock ) ;
list_for_each_entry ( smcd_dev , & smcd_dev_list . list , list ) {
if ( ! strncmp ( dev_name ( & smcd_dev - > dev ) , smcd_name ,
IB_DEVICE_NAME_MAX - 1 ) )
goto out ;
}
smcd_dev = NULL ;
out :
spin_unlock ( & smcd_dev_list . lock ) ;
return smcd_dev ;
}
2017-01-09 18:55:15 +03:00
/* Parse the supplied netlink attributes and fill a pnetentry structure.
* For ethernet and infiniband device names verify that the devices exist .
*/
2019-02-21 15:01:00 +03:00
static int smc_pnet_fill_entry ( struct net * net ,
struct smc_user_pnetentry * pnetelem ,
2017-01-09 18:55:15 +03:00
struct nlattr * tb [ ] )
{
2018-05-14 03:01:30 +03:00
char * string , * ibname ;
int rc ;
2017-01-09 18:55:15 +03:00
memset ( pnetelem , 0 , sizeof ( * pnetelem ) ) ;
INIT_LIST_HEAD ( & pnetelem - > list ) ;
2018-05-14 03:01:30 +03:00
rc = - EINVAL ;
if ( ! tb [ SMC_PNETID_NAME ] )
goto error ;
string = ( char * ) nla_data ( tb [ SMC_PNETID_NAME ] ) ;
if ( ! smc_pnetid_valid ( string , pnetelem - > pnet_name ) )
goto error ;
rc = - EINVAL ;
2019-02-21 15:01:00 +03:00
if ( tb [ SMC_PNETID_ETHNAME ] ) {
string = ( char * ) nla_data ( tb [ SMC_PNETID_ETHNAME ] ) ;
pnetelem - > ndev = dev_get_by_name ( net , string ) ;
if ( ! pnetelem - > ndev )
goto error ;
}
2018-05-14 03:01:30 +03:00
2019-02-21 15:01:02 +03:00
/* if this is not the initial namespace, stop here */
if ( net ! = & init_net )
return 0 ;
2018-05-14 03:01:30 +03:00
rc = - EINVAL ;
2019-02-21 15:01:00 +03:00
if ( tb [ SMC_PNETID_IBNAME ] ) {
ibname = ( char * ) nla_data ( tb [ SMC_PNETID_IBNAME ] ) ;
ibname = strim ( ibname ) ;
pnetelem - > smcibdev = smc_pnet_find_ib ( ibname ) ;
2019-02-21 15:01:01 +03:00
pnetelem - > smcd_dev = smc_pnet_find_smcd ( ibname ) ;
if ( ! pnetelem - > smcibdev & & ! pnetelem - > smcd_dev )
2019-02-21 15:01:00 +03:00
goto error ;
if ( pnetelem - > smcibdev ) {
if ( ! tb [ SMC_PNETID_IBPORT ] )
goto error ;
pnetelem - > ib_port = nla_get_u8 ( tb [ SMC_PNETID_IBPORT ] ) ;
if ( pnetelem - > ib_port < 1 | |
pnetelem - > ib_port > SMC_MAX_PORTS )
goto error ;
}
}
2018-05-14 03:01:30 +03:00
2017-01-09 18:55:15 +03:00
return 0 ;
error :
if ( pnetelem - > ndev )
dev_put ( pnetelem - > ndev ) ;
return rc ;
}
/* Convert an smc_pnetentry to a netlink attribute sequence */
2019-02-21 15:01:00 +03:00
static int smc_pnet_set_nla ( struct sk_buff * msg ,
struct smc_user_pnetentry * pnetelem )
2017-01-09 18:55:15 +03:00
{
2019-02-21 15:01:00 +03:00
if ( nla_put_string ( msg , SMC_PNETID_NAME , pnetelem - > pnet_name ) )
2017-01-09 18:55:15 +03:00
return - 1 ;
2019-02-21 15:01:00 +03:00
if ( pnetelem - > ndev ) {
if ( nla_put_string ( msg , SMC_PNETID_ETHNAME ,
pnetelem - > ndev - > name ) )
return - 1 ;
} else {
if ( nla_put_string ( msg , SMC_PNETID_ETHNAME , " n/a " ) )
return - 1 ;
2017-01-09 18:55:15 +03:00
}
2019-02-21 15:01:00 +03:00
if ( pnetelem - > smcibdev ) {
if ( nla_put_string ( msg , SMC_PNETID_IBNAME ,
2019-02-21 15:01:03 +03:00
dev_name ( pnetelem - > smcibdev - > ibdev - > dev . parent ) ) | |
2019-02-21 15:01:00 +03:00
nla_put_u8 ( msg , SMC_PNETID_IBPORT , pnetelem - > ib_port ) )
return - 1 ;
2019-02-21 15:01:01 +03:00
} else if ( pnetelem - > smcd_dev ) {
if ( nla_put_string ( msg , SMC_PNETID_IBNAME ,
dev_name ( & pnetelem - > smcd_dev - > dev ) ) | |
nla_put_u8 ( msg , SMC_PNETID_IBPORT , 1 ) )
return - 1 ;
2019-02-21 15:01:00 +03:00
} else {
if ( nla_put_string ( msg , SMC_PNETID_IBNAME , " n/a " ) | |
nla_put_u8 ( msg , SMC_PNETID_IBPORT , 0xff ) )
return - 1 ;
2017-01-09 18:55:15 +03:00
}
2019-02-21 15:01:00 +03:00
return 0 ;
2017-01-09 18:55:15 +03:00
}
static int smc_pnet_add ( struct sk_buff * skb , struct genl_info * info )
{
struct net * net = genl_info_net ( info ) ;
2019-02-21 15:01:00 +03:00
struct smc_user_pnetentry pnetelem ;
2019-02-21 15:01:02 +03:00
struct smc_pnettable * pnettable ;
struct smc_net * sn ;
2017-01-09 18:55:15 +03:00
int rc ;
2019-02-21 15:01:02 +03:00
/* get pnettable for namespace */
sn = net_generic ( net , smc_net_id ) ;
pnettable = & sn - > pnettable ;
2019-02-21 15:01:00 +03:00
rc = smc_pnet_fill_entry ( net , & pnetelem , info - > attrs ) ;
2017-01-09 18:55:15 +03:00
if ( ! rc )
2019-02-21 15:01:02 +03:00
rc = smc_pnet_enter ( pnettable , & pnetelem ) ;
2019-02-21 15:01:00 +03:00
if ( pnetelem . ndev )
dev_put ( pnetelem . ndev ) ;
2017-01-09 18:55:15 +03:00
return rc ;
}
static int smc_pnet_del ( struct sk_buff * skb , struct genl_info * info )
{
2019-02-21 15:01:02 +03:00
struct net * net = genl_info_net ( info ) ;
2018-05-14 03:01:30 +03:00
if ( ! info - > attrs [ SMC_PNETID_NAME ] )
return - EINVAL ;
2019-02-21 15:01:02 +03:00
return smc_pnet_remove_by_pnetid ( net ,
2017-01-09 18:55:15 +03:00
( char * ) nla_data ( info - > attrs [ SMC_PNETID_NAME ] ) ) ;
}
static int smc_pnet_dump_start ( struct netlink_callback * cb )
{
cb - > args [ 0 ] = 0 ;
return 0 ;
}
static int smc_pnet_dumpinfo ( struct sk_buff * skb ,
u32 portid , u32 seq , u32 flags ,
2019-02-21 15:01:00 +03:00
struct smc_user_pnetentry * pnetelem )
2017-01-09 18:55:15 +03:00
{
void * hdr ;
hdr = genlmsg_put ( skb , portid , seq , & smc_pnet_nl_family ,
flags , SMC_PNETID_GET ) ;
if ( ! hdr )
return - ENOMEM ;
if ( smc_pnet_set_nla ( skb , pnetelem ) < 0 ) {
genlmsg_cancel ( skb , hdr ) ;
return - EMSGSIZE ;
}
genlmsg_end ( skb , hdr ) ;
return 0 ;
}
2019-02-21 15:01:02 +03:00
static int _smc_pnet_dump ( struct net * net , struct sk_buff * skb , u32 portid ,
u32 seq , u8 * pnetid , int start_idx )
2017-01-09 18:55:15 +03:00
{
2019-02-21 15:01:00 +03:00
struct smc_user_pnetentry tmp_entry ;
2019-02-21 15:01:02 +03:00
struct smc_pnettable * pnettable ;
2017-01-09 18:55:15 +03:00
struct smc_pnetentry * pnetelem ;
2019-02-21 15:01:00 +03:00
struct smc_ib_device * ibdev ;
2019-02-21 15:01:01 +03:00
struct smcd_dev * smcd_dev ;
2019-02-21 15:01:02 +03:00
struct smc_net * sn ;
2017-01-09 18:55:15 +03:00
int idx = 0 ;
2019-02-21 15:01:00 +03:00
int ibport ;
2017-01-09 18:55:15 +03:00
2019-02-21 15:01:02 +03:00
/* get pnettable for namespace */
sn = net_generic ( net , smc_net_id ) ;
pnettable = & sn - > pnettable ;
2019-02-21 15:01:00 +03:00
/* dump netdevices */
2019-02-21 15:01:02 +03:00
read_lock ( & pnettable - > lock ) ;
list_for_each_entry ( pnetelem , & pnettable - > pnetlist , list ) {
2019-02-21 15:01:00 +03:00
if ( pnetid & & ! smc_pnet_match ( pnetelem - > pnet_name , pnetid ) )
continue ;
if ( idx + + < start_idx )
2017-01-09 18:55:15 +03:00
continue ;
2019-02-21 15:01:00 +03:00
memset ( & tmp_entry , 0 , sizeof ( tmp_entry ) ) ;
memcpy ( & tmp_entry . pnet_name , pnetelem - > pnet_name ,
SMC_MAX_PNETID_LEN ) ;
tmp_entry . ndev = pnetelem - > ndev ;
if ( smc_pnet_dumpinfo ( skb , portid , seq , NLM_F_MULTI ,
& tmp_entry ) ) {
2017-01-09 18:55:15 +03:00
- - idx ;
break ;
}
}
2019-02-21 15:01:02 +03:00
read_unlock ( & pnettable - > lock ) ;
/* if this is not the initial namespace, stop here */
if ( net ! = & init_net )
return idx ;
2019-02-21 15:01:00 +03:00
/* dump ib devices */
spin_lock ( & smc_ib_devices . lock ) ;
list_for_each_entry ( ibdev , & smc_ib_devices . list , list ) {
for ( ibport = 0 ; ibport < SMC_MAX_PORTS ; ibport + + ) {
if ( ibdev - > pnetid_by_user [ ibport ] ) {
if ( pnetid & &
! smc_pnet_match ( ibdev - > pnetid [ ibport ] ,
pnetid ) )
continue ;
if ( idx + + < start_idx )
continue ;
memset ( & tmp_entry , 0 , sizeof ( tmp_entry ) ) ;
memcpy ( & tmp_entry . pnet_name ,
ibdev - > pnetid [ ibport ] ,
SMC_MAX_PNETID_LEN ) ;
tmp_entry . smcibdev = ibdev ;
tmp_entry . ib_port = ibport + 1 ;
if ( smc_pnet_dumpinfo ( skb , portid , seq ,
NLM_F_MULTI ,
& tmp_entry ) ) {
- - idx ;
break ;
}
}
}
}
spin_unlock ( & smc_ib_devices . lock ) ;
2019-02-21 15:01:01 +03:00
/* dump smcd devices */
spin_lock ( & smcd_dev_list . lock ) ;
list_for_each_entry ( smcd_dev , & smcd_dev_list . list , list ) {
if ( smcd_dev - > pnetid_by_user ) {
if ( pnetid & & ! smc_pnet_match ( smcd_dev - > pnetid , pnetid ) )
continue ;
if ( idx + + < start_idx )
continue ;
memset ( & tmp_entry , 0 , sizeof ( tmp_entry ) ) ;
memcpy ( & tmp_entry . pnet_name , smcd_dev - > pnetid ,
SMC_MAX_PNETID_LEN ) ;
tmp_entry . smcd_dev = smcd_dev ;
if ( smc_pnet_dumpinfo ( skb , portid , seq , NLM_F_MULTI ,
& tmp_entry ) ) {
- - idx ;
break ;
}
}
}
spin_unlock ( & smcd_dev_list . lock ) ;
2019-02-21 15:01:00 +03:00
return idx ;
}
static int smc_pnet_dump ( struct sk_buff * skb , struct netlink_callback * cb )
{
2019-02-21 15:01:02 +03:00
struct net * net = sock_net ( skb - > sk ) ;
2019-02-21 15:01:00 +03:00
int idx ;
2019-02-21 15:01:02 +03:00
idx = _smc_pnet_dump ( net , skb , NETLINK_CB ( cb - > skb ) . portid ,
2019-02-21 15:01:00 +03:00
cb - > nlh - > nlmsg_seq , NULL , cb - > args [ 0 ] ) ;
cb - > args [ 0 ] = idx ;
2017-01-09 18:55:15 +03:00
return skb - > len ;
}
2019-02-21 15:01:00 +03:00
/* Retrieve one PNETID entry */
static int smc_pnet_get ( struct sk_buff * skb , struct genl_info * info )
{
2019-02-21 15:01:02 +03:00
struct net * net = genl_info_net ( info ) ;
2019-02-21 15:01:00 +03:00
struct sk_buff * msg ;
void * hdr ;
if ( ! info - > attrs [ SMC_PNETID_NAME ] )
return - EINVAL ;
msg = nlmsg_new ( NLMSG_DEFAULT_SIZE , GFP_KERNEL ) ;
if ( ! msg )
return - ENOMEM ;
2019-02-21 15:01:02 +03:00
_smc_pnet_dump ( net , msg , info - > snd_portid , info - > snd_seq ,
2019-02-21 15:01:00 +03:00
nla_data ( info - > attrs [ SMC_PNETID_NAME ] ) , 0 ) ;
/* finish multi part message and send it */
hdr = nlmsg_put ( msg , info - > snd_portid , info - > snd_seq , NLMSG_DONE , 0 ,
NLM_F_MULTI ) ;
if ( ! hdr ) {
nlmsg_free ( msg ) ;
return - EMSGSIZE ;
}
return genlmsg_reply ( msg , info ) ;
}
2017-01-09 18:55:15 +03:00
/* Remove and delete all pnetids from pnet table.
*/
static int smc_pnet_flush ( struct sk_buff * skb , struct genl_info * info )
{
2019-02-21 15:01:02 +03:00
struct net * net = genl_info_net ( info ) ;
2019-04-11 12:17:33 +03:00
smc_pnet_remove_by_pnetid ( net , NULL ) ;
return 0 ;
2017-01-09 18:55:15 +03:00
}
/* SMC_PNETID generic netlink operation definition */
static const struct genl_ops smc_pnet_ops [ ] = {
{
. cmd = SMC_PNETID_GET ,
2019-04-26 15:07:31 +03:00
. validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP ,
2017-01-09 18:55:15 +03:00
. flags = GENL_ADMIN_PERM ,
. doit = smc_pnet_get ,
. dumpit = smc_pnet_dump ,
. start = smc_pnet_dump_start
} ,
{
. cmd = SMC_PNETID_ADD ,
2019-04-26 15:07:31 +03:00
. validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP ,
2017-01-09 18:55:15 +03:00
. flags = GENL_ADMIN_PERM ,
. doit = smc_pnet_add
} ,
{
. cmd = SMC_PNETID_DEL ,
2019-04-26 15:07:31 +03:00
. validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP ,
2017-01-09 18:55:15 +03:00
. flags = GENL_ADMIN_PERM ,
. doit = smc_pnet_del
} ,
{
. cmd = SMC_PNETID_FLUSH ,
2019-04-26 15:07:31 +03:00
. validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP ,
2017-01-09 18:55:15 +03:00
. flags = GENL_ADMIN_PERM ,
. doit = smc_pnet_flush
}
} ;
/* SMC_PNETID family definition */
2018-09-20 10:27:30 +03:00
static struct genl_family smc_pnet_nl_family __ro_after_init = {
2017-01-09 18:55:15 +03:00
. hdrsize = 0 ,
. name = SMCR_GENL_FAMILY_NAME ,
. version = SMCR_GENL_FAMILY_VERSION ,
. maxattr = SMC_PNETID_MAX ,
genetlink: make policy common to family
Since maxattr is common, the policy can't really differ sanely,
so make it common as well.
The only user that did in fact manage to make a non-common policy
is taskstats, which has to be really careful about it (since it's
still using a common maxattr!). This is no longer supported, but
we can fake it using pre_doit.
This reduces the size of e.g. nl80211.o (which has lots of commands):
text data bss dec hex filename
398745 14323 2240 415308 6564c net/wireless/nl80211.o (before)
397913 14331 2240 414484 65314 net/wireless/nl80211.o (after)
--------------------------------
-832 +8 0 -824
Which is obviously just 8 bytes for each command, and an added 8
bytes for the new policy pointer. I'm not sure why the ops list is
counted as .text though.
Most of the code transformations were done using the following spatch:
@ops@
identifier OPS;
expression POLICY;
@@
struct genl_ops OPS[] = {
...,
{
- .policy = POLICY,
},
...
};
@@
identifier ops.OPS;
expression ops.POLICY;
identifier fam;
expression M;
@@
struct genl_family fam = {
.ops = OPS,
.maxattr = M,
+ .policy = POLICY,
...
};
This also gets rid of devlink_nl_cmd_region_read_dumpit() accessing
the cb->data as ops, which we want to change in a later genl patch.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-03-22 00:51:02 +03:00
. policy = smc_pnet_policy ,
2017-01-09 18:55:15 +03:00
. netnsok = true ,
. module = THIS_MODULE ,
. ops = smc_pnet_ops ,
. n_ops = ARRAY_SIZE ( smc_pnet_ops )
} ;
static int smc_pnet_netdev_event ( struct notifier_block * this ,
unsigned long event , void * ptr )
{
struct net_device * event_dev = netdev_notifier_info_to_dev ( ptr ) ;
switch ( event ) {
case NETDEV_REBOOT :
case NETDEV_UNREGISTER :
smc_pnet_remove_by_ndev ( event_dev ) ;
2018-06-28 20:05:04 +03:00
return NOTIFY_OK ;
2017-01-09 18:55:15 +03:00
default :
2018-06-28 20:05:04 +03:00
return NOTIFY_DONE ;
2017-01-09 18:55:15 +03:00
}
}
static struct notifier_block smc_netdev_notifier = {
. notifier_call = smc_pnet_netdev_event
} ;
2019-02-21 15:01:02 +03:00
/* init network namespace */
int smc_pnet_net_init ( struct net * net )
{
struct smc_net * sn = net_generic ( net , smc_net_id ) ;
struct smc_pnettable * pnettable = & sn - > pnettable ;
INIT_LIST_HEAD ( & pnettable - > pnetlist ) ;
rwlock_init ( & pnettable - > lock ) ;
return 0 ;
}
2017-01-09 18:55:15 +03:00
int __init smc_pnet_init ( void )
{
int rc ;
rc = genl_register_family ( & smc_pnet_nl_family ) ;
if ( rc )
return rc ;
rc = register_netdevice_notifier ( & smc_netdev_notifier ) ;
if ( rc )
genl_unregister_family ( & smc_pnet_nl_family ) ;
return rc ;
}
2019-02-21 15:01:02 +03:00
/* exit network namespace */
void smc_pnet_net_exit ( struct net * net )
{
/* flush pnet table */
smc_pnet_remove_by_pnetid ( net , NULL ) ;
}
2017-01-09 18:55:15 +03:00
void smc_pnet_exit ( void )
{
unregister_netdevice_notifier ( & smc_netdev_notifier ) ;
genl_unregister_family ( & smc_pnet_nl_family ) ;
}
2018-06-28 20:05:05 +03:00
/* Determine one base device for stacked net devices.
* If the lower device level contains more than one devices
* ( for instance with bonding slaves ) , just the first device
* is used to reach a base device .
2017-01-09 18:55:15 +03:00
*/
2018-06-28 20:05:05 +03:00
static struct net_device * pnet_find_base_ndev ( struct net_device * ndev )
2017-01-09 18:55:15 +03:00
{
2018-06-28 20:05:05 +03:00
int i , nest_lvl ;
2017-01-09 18:55:15 +03:00
2018-06-28 20:05:05 +03:00
rtnl_lock ( ) ;
nest_lvl = dev_get_nest_level ( ndev ) ;
for ( i = 0 ; i < nest_lvl ; i + + ) {
struct list_head * lower = & ndev - > adj_list . lower ;
if ( list_empty ( lower ) )
break ;
lower = lower - > next ;
ndev = netdev_lower_get_next ( ndev , & lower ) ;
}
rtnl_unlock ( ) ;
return ndev ;
}
2019-02-21 15:01:02 +03:00
static int smc_pnet_find_ndev_pnetid_by_table ( struct net_device * ndev ,
2019-02-21 15:01:00 +03:00
u8 * pnetid )
{
2019-02-21 15:01:02 +03:00
struct smc_pnettable * pnettable ;
struct net * net = dev_net ( ndev ) ;
2019-02-21 15:01:00 +03:00
struct smc_pnetentry * pnetelem ;
2019-02-21 15:01:02 +03:00
struct smc_net * sn ;
2019-02-21 15:01:00 +03:00
int rc = - ENOENT ;
2019-02-21 15:01:02 +03:00
/* get pnettable for namespace */
sn = net_generic ( net , smc_net_id ) ;
pnettable = & sn - > pnettable ;
read_lock ( & pnettable - > lock ) ;
list_for_each_entry ( pnetelem , & pnettable - > pnetlist , list ) {
if ( ndev = = pnetelem - > ndev ) {
2019-02-21 15:01:00 +03:00
/* get pnetid of netdev device */
memcpy ( pnetid , pnetelem - > pnet_name , SMC_MAX_PNETID_LEN ) ;
rc = 0 ;
break ;
}
}
2019-02-21 15:01:02 +03:00
read_unlock ( & pnettable - > lock ) ;
2019-02-21 15:01:00 +03:00
return rc ;
}
2019-02-28 17:10:08 +03:00
/* if handshake network device belongs to a roce device, return its
* IB device and port
*/
static void smc_pnet_find_rdma_dev ( struct net_device * netdev ,
2019-04-12 13:57:26 +03:00
struct smc_init_info * ini )
2019-02-28 17:10:08 +03:00
{
struct smc_ib_device * ibdev ;
spin_lock ( & smc_ib_devices . lock ) ;
list_for_each_entry ( ibdev , & smc_ib_devices . list , list ) {
struct net_device * ndev ;
int i ;
for ( i = 1 ; i < = SMC_MAX_PORTS ; i + + ) {
if ( ! rdma_is_port_valid ( ibdev - > ibdev , i ) )
continue ;
if ( ! ibdev - > ibdev - > ops . get_netdev )
continue ;
ndev = ibdev - > ibdev - > ops . get_netdev ( ibdev - > ibdev , i ) ;
if ( ! ndev )
continue ;
dev_put ( ndev ) ;
if ( netdev = = ndev & &
smc_ib_port_active ( ibdev , i ) & &
2019-04-12 13:57:26 +03:00
! smc_ib_determine_gid ( ibdev , i , ini - > vlan_id ,
ini - > ib_gid , NULL ) ) {
ini - > ib_dev = ibdev ;
ini - > ib_port = i ;
2019-02-28 17:10:08 +03:00
break ;
}
}
}
spin_unlock ( & smc_ib_devices . lock ) ;
}
2018-06-28 20:05:05 +03:00
/* Determine the corresponding IB device port based on the hardware PNETID.
2018-07-25 17:35:31 +03:00
* Searching stops at the first matching active IB device port with vlan_id
* configured .
2019-02-28 17:10:08 +03:00
* If nothing found , check pnetid table .
* If nothing found , try to use handshake device
2018-06-28 20:05:05 +03:00
*/
static void smc_pnet_find_roce_by_pnetid ( struct net_device * ndev ,
2019-04-12 13:57:26 +03:00
struct smc_init_info * ini )
2018-06-28 20:05:05 +03:00
{
u8 ndev_pnetid [ SMC_MAX_PNETID_LEN ] ;
struct smc_ib_device * ibdev ;
int i ;
ndev = pnet_find_base_ndev ( ndev ) ;
if ( smc_pnetid_by_dev_port ( ndev - > dev . parent , ndev - > dev_port ,
2019-02-21 15:01:00 +03:00
ndev_pnetid ) & &
2019-02-28 17:10:08 +03:00
smc_pnet_find_ndev_pnetid_by_table ( ndev , ndev_pnetid ) ) {
2019-04-12 13:57:26 +03:00
smc_pnet_find_rdma_dev ( ndev , ini ) ;
2018-06-28 20:05:05 +03:00
return ; /* pnetid could not be determined */
2019-02-28 17:10:08 +03:00
}
2018-06-28 20:05:05 +03:00
spin_lock ( & smc_ib_devices . lock ) ;
list_for_each_entry ( ibdev , & smc_ib_devices . list , list ) {
for ( i = 1 ; i < = SMC_MAX_PORTS ; i + + ) {
2018-07-25 17:35:31 +03:00
if ( ! rdma_is_port_valid ( ibdev - > ibdev , i ) )
continue ;
2019-02-21 15:01:00 +03:00
if ( smc_pnet_match ( ibdev - > pnetid [ i - 1 ] , ndev_pnetid ) & &
2018-07-25 17:35:31 +03:00
smc_ib_port_active ( ibdev , i ) & &
2019-04-12 13:57:26 +03:00
! smc_ib_determine_gid ( ibdev , i , ini - > vlan_id ,
ini - > ib_gid , NULL ) ) {
ini - > ib_dev = ibdev ;
ini - > ib_port = i ;
2018-07-25 17:35:31 +03:00
goto out ;
2018-06-28 20:05:05 +03:00
}
}
}
2018-07-25 17:35:31 +03:00
out :
2018-06-28 20:05:05 +03:00
spin_unlock ( & smc_ib_devices . lock ) ;
}
2018-06-28 20:05:08 +03:00
static void smc_pnet_find_ism_by_pnetid ( struct net_device * ndev ,
2019-04-12 13:57:26 +03:00
struct smc_init_info * ini )
2018-06-28 20:05:08 +03:00
{
u8 ndev_pnetid [ SMC_MAX_PNETID_LEN ] ;
struct smcd_dev * ismdev ;
ndev = pnet_find_base_ndev ( ndev ) ;
if ( smc_pnetid_by_dev_port ( ndev - > dev . parent , ndev - > dev_port ,
2019-02-21 15:01:01 +03:00
ndev_pnetid ) & &
smc_pnet_find_ndev_pnetid_by_table ( ndev , ndev_pnetid ) )
2018-06-28 20:05:08 +03:00
return ; /* pnetid could not be determined */
spin_lock ( & smcd_dev_list . lock ) ;
list_for_each_entry ( ismdev , & smcd_dev_list . list , list ) {
2019-02-21 15:01:01 +03:00
if ( smc_pnet_match ( ismdev - > pnetid , ndev_pnetid ) ) {
2019-04-12 13:57:26 +03:00
ini - > ism_dev = ismdev ;
2018-06-28 20:05:08 +03:00
break ;
}
}
spin_unlock ( & smcd_dev_list . lock ) ;
}
2018-06-28 20:05:05 +03:00
/* PNET table analysis for a given sock:
* determine ib_device and port belonging to used internal TCP socket
* ethernet interface .
*/
2019-04-12 13:57:26 +03:00
void smc_pnet_find_roce_resource ( struct sock * sk , struct smc_init_info * ini )
2018-06-28 20:05:05 +03:00
{
struct dst_entry * dst = sk_dst_get ( sk ) ;
2019-04-12 13:57:26 +03:00
ini - > ib_dev = NULL ;
ini - > ib_port = 0 ;
2018-06-28 20:05:05 +03:00
if ( ! dst )
goto out ;
if ( ! dst - > dev )
goto out_rel ;
2019-04-12 13:57:26 +03:00
smc_pnet_find_roce_by_pnetid ( dst - > dev , ini ) ;
2018-06-28 20:05:05 +03:00
2017-01-09 18:55:15 +03:00
out_rel :
dst_release ( dst ) ;
2018-06-28 20:05:05 +03:00
out :
return ;
2017-01-09 18:55:15 +03:00
}
2018-06-28 20:05:08 +03:00
2019-04-12 13:57:26 +03:00
void smc_pnet_find_ism_resource ( struct sock * sk , struct smc_init_info * ini )
2018-06-28 20:05:08 +03:00
{
struct dst_entry * dst = sk_dst_get ( sk ) ;
2019-04-12 13:57:26 +03:00
ini - > ism_dev = NULL ;
2018-06-28 20:05:08 +03:00
if ( ! dst )
goto out ;
if ( ! dst - > dev )
goto out_rel ;
2019-04-12 13:57:26 +03:00
smc_pnet_find_ism_by_pnetid ( dst - > dev , ini ) ;
2018-06-28 20:05:08 +03:00
out_rel :
dst_release ( dst ) ;
out :
return ;
}