dibs: Local gid for dibs devices
Define a uuid_t GID attribute to identify a dibs device. SMC uses 64 Bit and 128 Bit Global Identifiers (GIDs) per device, that need to be sent via the SMC protocol. Because the smc code uses integers, network endianness and host endianness need to be considered. Avoid this in the dibs layer by using uuid_t byte arrays. Future patches could change SMC to use uuid_t. For now conversion helper functions are introduced. ISM devices provide 64 Bit GIDs. Map them to dibs uuid_t GIDs like this: _________________________________________ | 64 Bit ISM-vPCI GID | 00000000_00000000 | ----------------------------------------- If interpreted as UUID [1], this would be interpreted as the UIID variant, that is reserved for NCS backward compatibility. So it will not collide with UUIDs that were generated according to the standard. smc_loopback already uses version 4 UUIDs as 128 Bit GIDs, move that to dibs loopback. A temporary change to smc_lo_query_rgid() is required, that will be moved to dibs_loopback with a follow-on patch. Provide gid of a dibs device as sysfs read-only attribute. Link: https://datatracker.ietf.org/doc/html/rfc4122 [1] Signed-off-by: Alexandra Winter <wintera@linux.ibm.com> Reviewed-by: Julian Ruess <julianr@linux.ibm.com> Reviewed-by: Mahanta Jambigi <mjambigi@linux.ibm.com> Link: https://patch.msgid.link/20250918110500.1731261-11-wintera@linux.ibm.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>pull/1354/merge
parent
8047373498
commit
05e68d8ded
|
|
@ -46,6 +46,7 @@ static int dibs_lo_dev_probe(void)
|
|||
|
||||
ldev->dibs = dibs;
|
||||
dibs->drv_priv = ldev;
|
||||
uuid_gen(&dibs->gid);
|
||||
dibs->ops = &dibs_lo_ops;
|
||||
|
||||
dibs->dev.parent = NULL;
|
||||
|
|
|
|||
|
|
@ -114,6 +114,17 @@ struct dibs_dev *dibs_dev_alloc(void)
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(dibs_dev_alloc);
|
||||
|
||||
static ssize_t gid_show(struct device *dev, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct dibs_dev *dibs;
|
||||
|
||||
dibs = container_of(dev, struct dibs_dev, dev);
|
||||
|
||||
return sysfs_emit(buf, "%pUb\n", &dibs->gid);
|
||||
}
|
||||
static DEVICE_ATTR_RO(gid);
|
||||
|
||||
static ssize_t fabric_id_show(struct device *dev, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
|
|
@ -128,6 +139,7 @@ static ssize_t fabric_id_show(struct device *dev, struct device_attribute *attr,
|
|||
static DEVICE_ATTR_RO(fabric_id);
|
||||
|
||||
static struct attribute *dibs_dev_attrs[] = {
|
||||
&dev_attr_gid.attr,
|
||||
&dev_attr_fabric_id.attr,
|
||||
NULL,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -67,6 +67,15 @@ union ism_reg_ieq {
|
|||
} response;
|
||||
} __aligned(16);
|
||||
|
||||
/* ISM-vPCI devices provide 64 Bit GIDs
|
||||
* Map them to ISM UUID GIDs like this:
|
||||
* _________________________________________
|
||||
* | 64 Bit ISM-vPCI GID | 00000000_00000000 |
|
||||
* -----------------------------------------
|
||||
* This will be interpreted as a UIID variant, that is reserved
|
||||
* for NCS backward compatibility. So it will not collide with
|
||||
* proper UUIDs.
|
||||
*/
|
||||
union ism_read_gid {
|
||||
struct {
|
||||
struct ism_req_hdr hdr;
|
||||
|
|
|
|||
|
|
@ -272,8 +272,9 @@ static int unregister_ieq(struct ism_dev *ism)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int ism_read_local_gid(struct ism_dev *ism)
|
||||
static int ism_read_local_gid(struct dibs_dev *dibs)
|
||||
{
|
||||
struct ism_dev *ism = dibs->drv_priv;
|
||||
union ism_read_gid cmd;
|
||||
int ret;
|
||||
|
||||
|
|
@ -285,7 +286,8 @@ static int ism_read_local_gid(struct ism_dev *ism)
|
|||
if (ret)
|
||||
goto out;
|
||||
|
||||
ism->local_gid = cmd.response.gid;
|
||||
memset(&dibs->gid, 0, sizeof(dibs->gid));
|
||||
memcpy(&dibs->gid, &cmd.response.gid, sizeof(cmd.response.gid));
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -563,10 +565,6 @@ static int ism_dev_init(struct ism_dev *ism)
|
|||
if (ret)
|
||||
goto unreg_sba;
|
||||
|
||||
ret = ism_read_local_gid(ism);
|
||||
if (ret)
|
||||
goto unreg_ieq;
|
||||
|
||||
if (!ism_add_vlan_id(ism, ISM_RESERVED_VLANID))
|
||||
/* hardware is V2 capable */
|
||||
ism_v2_capable = true;
|
||||
|
|
@ -588,8 +586,6 @@ static int ism_dev_init(struct ism_dev *ism)
|
|||
query_info(ism);
|
||||
return 0;
|
||||
|
||||
unreg_ieq:
|
||||
unregister_ieq(ism);
|
||||
unreg_sba:
|
||||
unregister_sba(ism);
|
||||
free_irq:
|
||||
|
|
@ -672,6 +668,11 @@ static int ism_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
|||
if (ret)
|
||||
goto err_dibs;
|
||||
|
||||
/* after ism_dev_init() we can call ism function to set gid */
|
||||
ret = ism_read_local_gid(dibs);
|
||||
if (ret)
|
||||
goto err_ism;
|
||||
|
||||
dibs->dev.parent = &pdev->dev;
|
||||
|
||||
zdev = to_zpci(pdev);
|
||||
|
|
@ -841,18 +842,6 @@ static int smcd_supports_v2(void)
|
|||
return ism_v2_capable;
|
||||
}
|
||||
|
||||
static u64 ism_get_local_gid(struct ism_dev *ism)
|
||||
{
|
||||
return ism->local_gid;
|
||||
}
|
||||
|
||||
static void smcd_get_local_gid(struct smcd_dev *smcd,
|
||||
struct smcd_gid *smcd_gid)
|
||||
{
|
||||
smcd_gid->gid = ism_get_local_gid(smcd->priv);
|
||||
smcd_gid->gid_ext = 0;
|
||||
}
|
||||
|
||||
static const struct smcd_ops ism_smcd_ops = {
|
||||
.query_remote_gid = smcd_query_rgid,
|
||||
.register_dmb = smcd_register_dmb,
|
||||
|
|
@ -864,7 +853,6 @@ static const struct smcd_ops ism_smcd_ops = {
|
|||
.signal_event = smcd_signal_ieq,
|
||||
.move_data = smcd_move,
|
||||
.supports_v2 = smcd_supports_v2,
|
||||
.get_local_gid = smcd_get_local_gid,
|
||||
};
|
||||
|
||||
const struct smcd_ops *ism_get_smcd_ops(void)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
#define _DIBS_H
|
||||
|
||||
#include <linux/device.h>
|
||||
#include <linux/uuid.h>
|
||||
|
||||
/* DIBS - Direct Internal Buffer Sharing - concept
|
||||
* -----------------------------------------------
|
||||
* In the case of multiple system sharing the same hardware, dibs fabrics can
|
||||
|
|
@ -138,6 +140,7 @@ struct dibs_dev {
|
|||
struct device dev;
|
||||
/* To be filled by device driver, before calling dibs_dev_add(): */
|
||||
const struct dibs_dev_ops *ops;
|
||||
uuid_t gid;
|
||||
/* priv pointer for device driver */
|
||||
void *drv_priv;
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ struct ism_dev {
|
|||
struct ism_eq *ieq;
|
||||
dma_addr_t ieq_dma_addr;
|
||||
|
||||
u64 local_gid;
|
||||
int ieq_idx;
|
||||
|
||||
struct ism_client *subs[MAX_CLIENTS];
|
||||
|
|
|
|||
|
|
@ -62,7 +62,6 @@ struct smcd_ops {
|
|||
bool sf, unsigned int offset, void *data,
|
||||
unsigned int size);
|
||||
int (*supports_v2)(void);
|
||||
void (*get_local_gid)(struct smcd_dev *dev, struct smcd_gid *gid);
|
||||
|
||||
/* optional operations */
|
||||
int (*add_vlan_id)(struct smcd_dev *dev, u64 vlan_id);
|
||||
|
|
|
|||
|
|
@ -916,7 +916,7 @@ int smc_clc_send_proposal(struct smc_sock *smc, struct smc_init_info *ini)
|
|||
/* add SMC-D specifics */
|
||||
if (ini->ism_dev[0]) {
|
||||
smcd = ini->ism_dev[0];
|
||||
smcd->ops->get_local_gid(smcd, &smcd_gid);
|
||||
copy_to_smcdgid(&smcd_gid, &smcd->dibs->gid);
|
||||
pclc_smcd->ism.gid = htonll(smcd_gid.gid);
|
||||
pclc_smcd->ism.chid =
|
||||
htons(smc_ism_get_chid(ini->ism_dev[0]));
|
||||
|
|
@ -966,7 +966,7 @@ int smc_clc_send_proposal(struct smc_sock *smc, struct smc_init_info *ini)
|
|||
if (ini->ism_offered_cnt) {
|
||||
for (i = 1; i <= ini->ism_offered_cnt; i++) {
|
||||
smcd = ini->ism_dev[i];
|
||||
smcd->ops->get_local_gid(smcd, &smcd_gid);
|
||||
copy_to_smcdgid(&smcd_gid, &smcd->dibs->gid);
|
||||
gidchids[entry].chid =
|
||||
htons(smc_ism_get_chid(ini->ism_dev[i]));
|
||||
gidchids[entry].gid = htonll(smcd_gid.gid);
|
||||
|
|
@ -1059,7 +1059,7 @@ smcd_clc_prep_confirm_accept(struct smc_connection *conn,
|
|||
/* SMC-D specific settings */
|
||||
memcpy(clc->hdr.eyecatcher, SMCD_EYECATCHER,
|
||||
sizeof(SMCD_EYECATCHER));
|
||||
smcd->ops->get_local_gid(smcd, &smcd_gid);
|
||||
copy_to_smcdgid(&smcd_gid, &smcd->dibs->gid);
|
||||
clc->hdr.typev1 = SMC_TYPE_D;
|
||||
clc->d0.gid = htonll(smcd_gid.gid);
|
||||
clc->d0.token = htonll(conn->rmb_desc->token);
|
||||
|
|
|
|||
|
|
@ -555,7 +555,7 @@ static int smc_nl_fill_smcd_lgr(struct smc_link_group *lgr,
|
|||
|
||||
if (nla_put_u32(skb, SMC_NLA_LGR_D_ID, *((u32 *)&lgr->id)))
|
||||
goto errattr;
|
||||
smcd->ops->get_local_gid(smcd, &smcd_gid);
|
||||
copy_to_smcdgid(&smcd_gid, &smcd->dibs->gid);
|
||||
if (nla_put_u64_64bit(skb, SMC_NLA_LGR_D_GID,
|
||||
smcd_gid.gid, SMC_NLA_LGR_D_PAD))
|
||||
goto errattr;
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ static int __smc_diag_dump(struct sock *sk, struct sk_buff *skb,
|
|||
dinfo.linkid = *((u32 *)conn->lgr->id);
|
||||
dinfo.peer_gid = conn->lgr->peer_gid.gid;
|
||||
dinfo.peer_gid_ext = conn->lgr->peer_gid.gid_ext;
|
||||
smcd->ops->get_local_gid(smcd, &smcd_gid);
|
||||
copy_to_smcdgid(&smcd_gid, &smcd->dibs->gid);
|
||||
dinfo.my_gid = smcd_gid.gid;
|
||||
dinfo.my_gid_ext = smcd_gid.gid_ext;
|
||||
dinfo.token = conn->rmb_desc->token;
|
||||
|
|
|
|||
|
|
@ -96,4 +96,26 @@ static inline bool smc_ism_is_loopback(struct dibs_dev *dibs)
|
|||
return (dibs->ops->get_fabric_id(dibs) == DIBS_LOOPBACK_FABRIC);
|
||||
}
|
||||
|
||||
static inline void copy_to_smcdgid(struct smcd_gid *sgid, uuid_t *dibs_gid)
|
||||
{
|
||||
__be64 temp;
|
||||
|
||||
memcpy(&temp, dibs_gid, sizeof(sgid->gid));
|
||||
sgid->gid = ntohll(temp);
|
||||
memcpy(&temp, (uint8_t *)dibs_gid + sizeof(sgid->gid),
|
||||
sizeof(sgid->gid_ext));
|
||||
sgid->gid_ext = ntohll(temp);
|
||||
}
|
||||
|
||||
static inline void copy_to_dibsgid(uuid_t *dibs_gid, struct smcd_gid *sgid)
|
||||
{
|
||||
__be64 temp;
|
||||
|
||||
temp = htonll(sgid->gid);
|
||||
memcpy(dibs_gid, &temp, sizeof(sgid->gid));
|
||||
temp = htonll(sgid->gid_ext);
|
||||
memcpy((uint8_t *)dibs_gid + sizeof(sgid->gid), &temp,
|
||||
sizeof(sgid->gid_ext));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include <linux/device.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/dibs.h>
|
||||
#include <net/smc.h>
|
||||
|
||||
#include "smc_cdc.h"
|
||||
|
|
@ -25,25 +26,14 @@
|
|||
|
||||
static struct smc_lo_dev *lo_dev;
|
||||
|
||||
static void smc_lo_generate_ids(struct smc_lo_dev *ldev)
|
||||
{
|
||||
struct smcd_gid *lgid = &ldev->local_gid;
|
||||
uuid_t uuid;
|
||||
|
||||
uuid_gen(&uuid);
|
||||
memcpy(&lgid->gid, &uuid, sizeof(lgid->gid));
|
||||
memcpy(&lgid->gid_ext, (u8 *)&uuid + sizeof(lgid->gid),
|
||||
sizeof(lgid->gid_ext));
|
||||
}
|
||||
|
||||
static int smc_lo_query_rgid(struct smcd_dev *smcd, struct smcd_gid *rgid,
|
||||
u32 vid_valid, u32 vid)
|
||||
{
|
||||
struct smc_lo_dev *ldev = smcd->priv;
|
||||
uuid_t temp;
|
||||
|
||||
copy_to_dibsgid(&temp, rgid);
|
||||
/* rgid should be the same as lgid */
|
||||
if (!ldev || rgid->gid != ldev->local_gid.gid ||
|
||||
rgid->gid_ext != ldev->local_gid.gid_ext)
|
||||
if (!uuid_equal(&temp, &smcd->dibs->gid))
|
||||
return -ENETUNREACH;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -245,15 +235,6 @@ static int smc_lo_move_data(struct smcd_dev *smcd, u64 dmb_tok,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void smc_lo_get_local_gid(struct smcd_dev *smcd,
|
||||
struct smcd_gid *smcd_gid)
|
||||
{
|
||||
struct smc_lo_dev *ldev = smcd->priv;
|
||||
|
||||
smcd_gid->gid = ldev->local_gid.gid;
|
||||
smcd_gid->gid_ext = ldev->local_gid.gid_ext;
|
||||
}
|
||||
|
||||
static const struct smcd_ops lo_ops = {
|
||||
.query_remote_gid = smc_lo_query_rgid,
|
||||
.register_dmb = smc_lo_register_dmb,
|
||||
|
|
@ -267,7 +248,6 @@ static const struct smcd_ops lo_ops = {
|
|||
.reset_vlan_required = NULL,
|
||||
.signal_event = NULL,
|
||||
.move_data = smc_lo_move_data,
|
||||
.get_local_gid = smc_lo_get_local_gid,
|
||||
};
|
||||
|
||||
const struct smcd_ops *smc_lo_get_smcd_ops(void)
|
||||
|
|
@ -277,7 +257,6 @@ const struct smcd_ops *smc_lo_get_smcd_ops(void)
|
|||
|
||||
static void smc_lo_dev_init(struct smc_lo_dev *ldev)
|
||||
{
|
||||
smc_lo_generate_ids(ldev);
|
||||
rwlock_init(&ldev->dmb_ht_lock);
|
||||
hash_init(ldev->dmb_ht);
|
||||
atomic_set(&ldev->dmb_cnt, 0);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ struct smc_lo_dmb_node {
|
|||
|
||||
struct smc_lo_dev {
|
||||
struct smcd_dev *smcd;
|
||||
struct smcd_gid local_gid;
|
||||
atomic_t dmb_cnt;
|
||||
rwlock_t dmb_ht_lock;
|
||||
DECLARE_BITMAP(sba_idx_mask, SMC_LO_MAX_DMBS);
|
||||
|
|
|
|||
Loading…
Reference in New Issue