Commit 201091eb authored by Ursula Braun's avatar Ursula Braun Committed by David S. Miller

net/smc: introduce System Enterprise ID (SEID)

SMCD version 2 defines a System Enterprise ID (short SEID).
This patch contains the SEID creation and adds the callback to
retrieve the created SEID.
Signed-off-by: default avatarUrsula Braun <ubraun@linux.ibm.com>
Signed-off-by: default avatarKarsten Graul <kgraul@linux.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3fc64937
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#define ISM_DMB_WORD_OFFSET 1 #define ISM_DMB_WORD_OFFSET 1
#define ISM_DMB_BIT_OFFSET (ISM_DMB_WORD_OFFSET * 32) #define ISM_DMB_BIT_OFFSET (ISM_DMB_WORD_OFFSET * 32)
#define ISM_NR_DMBS 1920 #define ISM_NR_DMBS 1920
#define ISM_IDENT_MASK 0x00FFFF
#define ISM_REG_SBA 0x1 #define ISM_REG_SBA 0x1
#define ISM_REG_IEQ 0x2 #define ISM_REG_IEQ 0x2
...@@ -206,6 +207,12 @@ struct ism_dev { ...@@ -206,6 +207,12 @@ struct ism_dev {
#define ISM_CREATE_REQ(dmb, idx, sf, offset) \ #define ISM_CREATE_REQ(dmb, idx, sf, offset) \
((dmb) | (idx) << 24 | (sf) << 23 | (offset)) ((dmb) | (idx) << 24 | (sf) << 23 | (offset))
struct ism_systemeid {
u8 seid_string[24];
u8 serial_number[4];
u8 type[4];
};
static inline void __ism_read_cmd(struct ism_dev *ism, void *data, static inline void __ism_read_cmd(struct ism_dev *ism, void *data,
unsigned long offset, unsigned long len) unsigned long offset, unsigned long len)
{ {
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
#include <linux/device.h> #include <linux/device.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/ctype.h>
#include <linux/processor.h>
#include <net/smc.h> #include <net/smc.h>
#include <asm/debug.h> #include <asm/debug.h>
...@@ -387,6 +389,31 @@ static int ism_move(struct smcd_dev *smcd, u64 dmb_tok, unsigned int idx, ...@@ -387,6 +389,31 @@ static int ism_move(struct smcd_dev *smcd, u64 dmb_tok, unsigned int idx,
return 0; return 0;
} }
static struct ism_systemeid SYSTEM_EID = {
.seid_string = "IBM-SYSZ-IBMSEID00000000",
.serial_number = "0000",
.type = "0000",
};
static void ism_create_system_eid(void)
{
struct cpuid id;
u16 ident_tail;
char tmp[5];
get_cpu_id(&id);
ident_tail = (u16)(id.ident & ISM_IDENT_MASK);
snprintf(tmp, 5, "%04X", ident_tail);
memcpy(&SYSTEM_EID.serial_number, tmp, 4);
snprintf(tmp, 5, "%04X", id.machine);
memcpy(&SYSTEM_EID.type, tmp, 4);
}
static void ism_get_system_eid(struct smcd_dev *smcd, u8 **eid)
{
*eid = &SYSTEM_EID.seid_string[0];
}
static void ism_handle_event(struct ism_dev *ism) static void ism_handle_event(struct ism_dev *ism)
{ {
struct smcd_event *entry; struct smcd_event *entry;
...@@ -443,6 +470,7 @@ static const struct smcd_ops ism_ops = { ...@@ -443,6 +470,7 @@ static const struct smcd_ops ism_ops = {
.reset_vlan_required = ism_reset_vlan_required, .reset_vlan_required = ism_reset_vlan_required,
.signal_event = ism_signal_ieq, .signal_event = ism_signal_ieq,
.move_data = ism_move, .move_data = ism_move,
.get_system_eid = ism_get_system_eid,
}; };
static int ism_dev_init(struct ism_dev *ism) static int ism_dev_init(struct ism_dev *ism)
...@@ -471,6 +499,10 @@ static int ism_dev_init(struct ism_dev *ism) ...@@ -471,6 +499,10 @@ static int ism_dev_init(struct ism_dev *ism)
if (ret) if (ret)
goto unreg_ieq; goto unreg_ieq;
if (!ism_add_vlan_id(ism->smcd, ISM_RESERVED_VLANID))
/* hardware is V2 capable */
ism_create_system_eid();
ret = smcd_register_dev(ism->smcd); ret = smcd_register_dev(ism->smcd);
if (ret) if (ret)
goto unreg_ieq; goto unreg_ieq;
...@@ -550,6 +582,9 @@ static void ism_dev_exit(struct ism_dev *ism) ...@@ -550,6 +582,9 @@ static void ism_dev_exit(struct ism_dev *ism)
struct pci_dev *pdev = ism->pdev; struct pci_dev *pdev = ism->pdev;
smcd_unregister_dev(ism->smcd); smcd_unregister_dev(ism->smcd);
if (SYSTEM_EID.serial_number[0] != '0' ||
SYSTEM_EID.type[0] != '0')
ism_del_vlan_id(ism->smcd, ISM_RESERVED_VLANID);
unregister_ieq(ism); unregister_ieq(ism);
unregister_sba(ism); unregister_sba(ism);
free_irq(pci_irq_vector(pdev, 0), ism); free_irq(pci_irq_vector(pdev, 0), ism);
......
...@@ -37,6 +37,8 @@ struct smcd_dmb { ...@@ -37,6 +37,8 @@ struct smcd_dmb {
#define ISM_EVENT_GID 1 #define ISM_EVENT_GID 1
#define ISM_EVENT_SWR 2 #define ISM_EVENT_SWR 2
#define ISM_RESERVED_VLANID 0x1FFF
#define ISM_ERROR 0xFFFF #define ISM_ERROR 0xFFFF
struct smcd_event { struct smcd_event {
...@@ -63,6 +65,7 @@ struct smcd_ops { ...@@ -63,6 +65,7 @@ struct smcd_ops {
int (*move_data)(struct smcd_dev *dev, u64 dmb_tok, unsigned int idx, int (*move_data)(struct smcd_dev *dev, u64 dmb_tok, unsigned int idx,
bool sf, unsigned int offset, void *data, bool sf, unsigned int offset, void *data,
unsigned int size); unsigned int size);
void (*get_system_eid)(struct smcd_dev *dev, u8 **eid);
}; };
struct smcd_dev { struct smcd_dev {
......
...@@ -2137,6 +2137,8 @@ static int __init smc_init(void) ...@@ -2137,6 +2137,8 @@ static int __init smc_init(void)
if (rc) if (rc)
return rc; return rc;
smc_ism_init();
rc = smc_pnet_init(); rc = smc_pnet_init();
if (rc) if (rc)
goto out_pernet_subsys; goto out_pernet_subsys;
......
...@@ -21,7 +21,9 @@ struct smcd_dev_list smcd_dev_list = { ...@@ -21,7 +21,9 @@ struct smcd_dev_list smcd_dev_list = {
.mutex = __MUTEX_INITIALIZER(smcd_dev_list.mutex) .mutex = __MUTEX_INITIALIZER(smcd_dev_list.mutex)
}; };
/* Test if an ISM communication is possible. */ bool smc_ism_v2_capable;
/* Test if an ISM communication is possible - same CPC */
int smc_ism_cantalk(u64 peer_gid, unsigned short vlan_id, struct smcd_dev *smcd) int smc_ism_cantalk(u64 peer_gid, unsigned short vlan_id, struct smcd_dev *smcd)
{ {
return smcd->ops->query_remote_gid(smcd, peer_gid, vlan_id ? 1 : 0, return smcd->ops->query_remote_gid(smcd, peer_gid, vlan_id ? 1 : 0,
...@@ -39,6 +41,11 @@ int smc_ism_write(struct smcd_dev *smcd, const struct smc_ism_position *pos, ...@@ -39,6 +41,11 @@ int smc_ism_write(struct smcd_dev *smcd, const struct smc_ism_position *pos,
return rc < 0 ? rc : 0; return rc < 0 ? rc : 0;
} }
void smc_ism_get_system_eid(struct smcd_dev *smcd, u8 **eid)
{
smcd->ops->get_system_eid(smcd, eid);
}
/* Set a connection using this DMBE. */ /* Set a connection using this DMBE. */
void smc_ism_set_conn(struct smc_connection *conn) void smc_ism_set_conn(struct smc_connection *conn)
{ {
...@@ -319,6 +326,13 @@ EXPORT_SYMBOL_GPL(smcd_alloc_dev); ...@@ -319,6 +326,13 @@ EXPORT_SYMBOL_GPL(smcd_alloc_dev);
int smcd_register_dev(struct smcd_dev *smcd) int smcd_register_dev(struct smcd_dev *smcd)
{ {
mutex_lock(&smcd_dev_list.mutex); mutex_lock(&smcd_dev_list.mutex);
if (list_empty(&smcd_dev_list.list)) {
u8 *system_eid = NULL;
smc_ism_get_system_eid(smcd, &system_eid);
if ((*system_eid) + 24 != '0' || (*system_eid) + 28 != '0')
smc_ism_v2_capable = true;
}
list_add_tail(&smcd->list, &smcd_dev_list.list); list_add_tail(&smcd->list, &smcd_dev_list.list);
mutex_unlock(&smcd_dev_list.mutex); mutex_unlock(&smcd_dev_list.mutex);
...@@ -399,3 +413,8 @@ void smcd_handle_irq(struct smcd_dev *smcd, unsigned int dmbno) ...@@ -399,3 +413,8 @@ void smcd_handle_irq(struct smcd_dev *smcd, unsigned int dmbno)
spin_unlock_irqrestore(&smcd->lock, flags); spin_unlock_irqrestore(&smcd->lock, flags);
} }
EXPORT_SYMBOL_GPL(smcd_handle_irq); EXPORT_SYMBOL_GPL(smcd_handle_irq);
void __init smc_ism_init(void)
{
smc_ism_v2_capable = false;
}
...@@ -20,6 +20,9 @@ struct smcd_dev_list { /* List of SMCD devices */ ...@@ -20,6 +20,9 @@ struct smcd_dev_list { /* List of SMCD devices */
}; };
extern struct smcd_dev_list smcd_dev_list; /* list of smcd devices */ extern struct smcd_dev_list smcd_dev_list; /* list of smcd devices */
extern bool smc_ism_v2_capable; /* HW supports ISM V2 and thus
* System EID is defined
*/
struct smc_ism_vlanid { /* VLAN id set on ISM device */ struct smc_ism_vlanid { /* VLAN id set on ISM device */
struct list_head list; struct list_head list;
...@@ -47,4 +50,6 @@ int smc_ism_unregister_dmb(struct smcd_dev *dev, struct smc_buf_desc *dmb_desc); ...@@ -47,4 +50,6 @@ int smc_ism_unregister_dmb(struct smcd_dev *dev, struct smc_buf_desc *dmb_desc);
int smc_ism_write(struct smcd_dev *dev, const struct smc_ism_position *pos, int smc_ism_write(struct smcd_dev *dev, const struct smc_ism_position *pos,
void *data, size_t len); void *data, size_t len);
int smc_ism_signal_shutdown(struct smc_link_group *lgr); int smc_ism_signal_shutdown(struct smc_link_group *lgr);
void smc_ism_get_system_eid(struct smcd_dev *dev, u8 **eid);
void smc_ism_init(void);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment