platform: add support for creating InfiniBand subdevices
This commit is contained in:
@@ -560,6 +560,23 @@ vlan_set_egress_map (NMPlatform *platform, int ifindex, int from, int to)
|
||||
return !!link_get (platform, ifindex);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
infiniband_partition_add (NMPlatform *platform, int parent, int p_key)
|
||||
{
|
||||
NMFakePlatformLink *parent_device;
|
||||
char *name;
|
||||
gboolean success;
|
||||
|
||||
parent_device = link_get (platform, parent);
|
||||
g_return_val_if_fail (parent_device != NULL, FALSE);
|
||||
|
||||
name = g_strdup_printf ("%s.%04x", parent_device->link.name, p_key);
|
||||
success = link_add (platform, name, NM_LINK_TYPE_INFINIBAND);
|
||||
g_free (name);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
veth_get_properties (NMPlatform *platform, int ifindex, NMPlatformVethProperties *props)
|
||||
{
|
||||
@@ -1042,6 +1059,8 @@ nm_fake_platform_class_init (NMFakePlatformClass *klass)
|
||||
platform_class->vlan_set_ingress_map = vlan_set_ingress_map;
|
||||
platform_class->vlan_set_egress_map = vlan_set_egress_map;
|
||||
|
||||
platform_class->infiniband_partition_add = infiniband_partition_add;
|
||||
|
||||
platform_class->veth_get_properties = veth_get_properties;
|
||||
platform_class->tun_get_properties = tun_get_properties;
|
||||
platform_class->macvlan_get_properties = macvlan_get_properties;
|
||||
|
@@ -1619,6 +1619,25 @@ slave_get_option (NMPlatform *platform, int slave, const char *option)
|
||||
return link_get_option (slave, slave_category (platform, slave), option);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
infiniband_partition_add (NMPlatform *platform, int parent, int p_key)
|
||||
{
|
||||
const char *parent_name;
|
||||
char *path, *id;
|
||||
gboolean success;
|
||||
|
||||
parent_name = nm_platform_link_get_name (parent);
|
||||
g_return_val_if_fail (parent_name != NULL, FALSE);
|
||||
|
||||
path = g_strdup_printf ("/sys/class/net/%s/create_child", parent_name);
|
||||
id = g_strdup_printf ("0x%04x", p_key);
|
||||
success = nm_platform_sysctl_set (path, id);
|
||||
g_free (id);
|
||||
g_free (path);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
veth_get_properties (NMPlatform *platform, int ifindex, NMPlatformVethProperties *props)
|
||||
{
|
||||
@@ -2414,6 +2433,8 @@ nm_linux_platform_class_init (NMLinuxPlatformClass *klass)
|
||||
platform_class->vlan_set_ingress_map = vlan_set_ingress_map;
|
||||
platform_class->vlan_set_egress_map = vlan_set_egress_map;
|
||||
|
||||
platform_class->infiniband_partition_add = infiniband_partition_add;
|
||||
|
||||
platform_class->veth_get_properties = veth_get_properties;
|
||||
platform_class->tun_get_properties = tun_get_properties;
|
||||
platform_class->macvlan_get_properties = macvlan_get_properties;
|
||||
|
@@ -175,6 +175,8 @@ nm_platform_get_error_msg (void)
|
||||
return "object not found";
|
||||
case NM_PLATFORM_ERROR_EXISTS:
|
||||
return "object already exists";
|
||||
case NM_PLATFORM_ERROR_WRONG_TYPE:
|
||||
return "object is wrong type";
|
||||
case NM_PLATFORM_ERROR_NOT_SLAVE:
|
||||
return "link not a slave";
|
||||
case NM_PLATFORM_ERROR_NO_FIRMWARE:
|
||||
@@ -956,6 +958,36 @@ nm_platform_vlan_set_egress_map (int ifindex, int from, int to)
|
||||
return klass->vlan_set_egress_map (platform, ifindex, from, to);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_platform_infiniband_partition_add (int parent, int p_key)
|
||||
{
|
||||
const char *parent_name;
|
||||
char *name;
|
||||
|
||||
reset_error ();
|
||||
|
||||
g_return_val_if_fail (parent >= 0, FALSE);
|
||||
g_return_val_if_fail (p_key >= 0, FALSE);
|
||||
g_return_val_if_fail (klass->infiniband_partition_add, FALSE);
|
||||
|
||||
if (nm_platform_link_get_type (parent) != NM_LINK_TYPE_INFINIBAND) {
|
||||
platform->error = NM_PLATFORM_ERROR_WRONG_TYPE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
parent_name = nm_platform_link_get_name (parent);
|
||||
name = g_strdup_printf ("%s.%04x", parent_name, p_key);
|
||||
if (nm_platform_link_exists (name)) {
|
||||
debug ("infiniband: already exists");
|
||||
platform->error = NM_PLATFORM_ERROR_EXISTS;
|
||||
g_free (name);
|
||||
return FALSE;
|
||||
}
|
||||
g_free (name);
|
||||
|
||||
return klass->infiniband_partition_add (platform, parent, p_key);
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_platform_veth_get_properties (int ifindex, NMPlatformVethProperties *props)
|
||||
{
|
||||
|
@@ -41,6 +41,8 @@ typedef enum {
|
||||
NM_PLATFORM_ERROR_NOT_FOUND,
|
||||
/* object already exists */
|
||||
NM_PLATFORM_ERROR_EXISTS,
|
||||
/* object is wrong type */
|
||||
NM_PLATFORM_ERROR_WRONG_TYPE,
|
||||
/* object is not a slave */
|
||||
NM_PLATFORM_ERROR_NOT_SLAVE,
|
||||
/* firmware is not found */
|
||||
@@ -235,6 +237,8 @@ typedef struct {
|
||||
gboolean (*vlan_set_ingress_map) (NMPlatform *, int ifindex, int from, int to);
|
||||
gboolean (*vlan_set_egress_map) (NMPlatform *, int ifindex, int from, int to);
|
||||
|
||||
gboolean (*infiniband_partition_add) (NMPlatform *, int parent, int p_key);
|
||||
|
||||
gboolean (*veth_get_properties) (NMPlatform *, int ifindex, NMPlatformVethProperties *properties);
|
||||
gboolean (*tun_get_properties) (NMPlatform *, int ifindex, NMPlatformTunProperties *properties);
|
||||
gboolean (*macvlan_get_properties) (NMPlatform *, int ifindex, NMPlatformMacvlanProperties *props);
|
||||
@@ -349,6 +353,8 @@ gboolean nm_platform_vlan_get_info (int ifindex, int *parent, int *vlanid);
|
||||
gboolean nm_platform_vlan_set_ingress_map (int ifindex, int from, int to);
|
||||
gboolean nm_platform_vlan_set_egress_map (int ifindex, int from, int to);
|
||||
|
||||
gboolean nm_platform_infiniband_partition_add (int parent, int p_key);
|
||||
|
||||
gboolean nm_platform_veth_get_properties (int ifindex, NMPlatformVethProperties *properties);
|
||||
gboolean nm_platform_tun_get_properties (int ifindex, NMPlatformTunProperties *properties);
|
||||
gboolean nm_platform_macvlan_get_properties (int ifindex, NMPlatformMacvlanProperties *props);
|
||||
|
Reference in New Issue
Block a user