Commit e3164533 authored by Or Gerlitz's avatar Or Gerlitz Committed by Roland Dreier

IB/ipath: Add P_Key change event support

Deliver P_Key_CHANGE event through the relevant IB device when
the local pkey table changes.
Signed-off-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
parent 64aa90f2
...@@ -726,7 +726,7 @@ static int add_pkey(struct ipath_devdata *dd, u16 key) ...@@ -726,7 +726,7 @@ static int add_pkey(struct ipath_devdata *dd, u16 key)
* @dd: the infinipath device * @dd: the infinipath device
* @pkeys: the PKEY table * @pkeys: the PKEY table
*/ */
static int set_pkeys(struct ipath_devdata *dd, u16 *pkeys) static int set_pkeys(struct ipath_devdata *dd, u16 *pkeys, u8 port)
{ {
struct ipath_portdata *pd; struct ipath_portdata *pd;
int i; int i;
...@@ -759,6 +759,7 @@ static int set_pkeys(struct ipath_devdata *dd, u16 *pkeys) ...@@ -759,6 +759,7 @@ static int set_pkeys(struct ipath_devdata *dd, u16 *pkeys)
} }
if (changed) { if (changed) {
u64 pkey; u64 pkey;
struct ib_event event;
pkey = (u64) dd->ipath_pkeys[0] | pkey = (u64) dd->ipath_pkeys[0] |
((u64) dd->ipath_pkeys[1] << 16) | ((u64) dd->ipath_pkeys[1] << 16) |
...@@ -768,12 +769,17 @@ static int set_pkeys(struct ipath_devdata *dd, u16 *pkeys) ...@@ -768,12 +769,17 @@ static int set_pkeys(struct ipath_devdata *dd, u16 *pkeys)
(unsigned long long) pkey); (unsigned long long) pkey);
ipath_write_kreg(dd, dd->ipath_kregs->kr_partitionkey, ipath_write_kreg(dd, dd->ipath_kregs->kr_partitionkey,
pkey); pkey);
event.event = IB_EVENT_PKEY_CHANGE;
event.device = &dd->verbs_dev->ibdev;
event.element.port_num = port;
ib_dispatch_event(&event);
} }
return 0; return 0;
} }
static int recv_subn_set_pkeytable(struct ib_smp *smp, static int recv_subn_set_pkeytable(struct ib_smp *smp,
struct ib_device *ibdev) struct ib_device *ibdev, u8 port)
{ {
u32 startpx = 32 * (be32_to_cpu(smp->attr_mod) & 0xffff); u32 startpx = 32 * (be32_to_cpu(smp->attr_mod) & 0xffff);
__be16 *p = (__be16 *) smp->data; __be16 *p = (__be16 *) smp->data;
...@@ -784,7 +790,7 @@ static int recv_subn_set_pkeytable(struct ib_smp *smp, ...@@ -784,7 +790,7 @@ static int recv_subn_set_pkeytable(struct ib_smp *smp,
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
q[i] = be16_to_cpu(p[i]); q[i] = be16_to_cpu(p[i]);
if (startpx != 0 || set_pkeys(dev->dd, q) != 0) if (startpx != 0 || set_pkeys(dev->dd, q, port) != 0)
smp->status |= IB_SMP_INVALID_FIELD; smp->status |= IB_SMP_INVALID_FIELD;
return recv_subn_get_pkeytable(smp, ibdev); return recv_subn_get_pkeytable(smp, ibdev);
...@@ -1342,7 +1348,7 @@ static int process_subn(struct ib_device *ibdev, int mad_flags, ...@@ -1342,7 +1348,7 @@ static int process_subn(struct ib_device *ibdev, int mad_flags,
ret = recv_subn_set_portinfo(smp, ibdev, port_num); ret = recv_subn_set_portinfo(smp, ibdev, port_num);
goto bail; goto bail;
case IB_SMP_ATTR_PKEY_TABLE: case IB_SMP_ATTR_PKEY_TABLE:
ret = recv_subn_set_pkeytable(smp, ibdev); ret = recv_subn_set_pkeytable(smp, ibdev, port_num);
goto bail; goto bail;
case IB_SMP_ATTR_SM_INFO: case IB_SMP_ATTR_SM_INFO:
if (dev->port_cap_flags & IB_PORT_SM_DISABLED) { if (dev->port_cap_flags & IB_PORT_SM_DISABLED) {
......
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