Commit bd3e64c1 authored by Dean Nelson's avatar Dean Nelson Committed by Linus Torvalds

sgi-xp: setup the notify GRU message queue

Setup the notify GRU message queue that is used for sending user messages
on UV systems.
Signed-off-by: default avatarDean Nelson <dcn@sgi.com>
Cc: Jack Steiner <steiner@sgi.com>
Cc: "Luck, Tony" <tony.luck@intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 5b8669df
...@@ -87,39 +87,18 @@ ...@@ -87,39 +87,18 @@
#endif #endif
/* /*
* The format of an XPC message is as follows: * Define macro, XPC_MSG_SIZE(), is provided for the user
*
* +-------+--------------------------------+
* | flags |////////////////////////////////|
* +-------+--------------------------------+
* | message # |
* +----------------------------------------+
* | payload (user-defined message) |
* | |
* :
* | |
* +----------------------------------------+
*
* The size of the payload is defined by the user via xpc_connect(). A user-
* defined message resides in the payload area.
*
* The size of a message entry (within a message queue) must be a cacheline
* sized multiple in order to facilitate the BTE transfer of messages from one
* message queue to another. A macro, XPC_MSG_SIZE(), is provided for the user
* that wants to fit as many msg entries as possible in a given memory size * that wants to fit as many msg entries as possible in a given memory size
* (e.g. a memory page). * (e.g. a memory page).
*/ */
struct xpc_msg { #define XPC_MSG_MAX_SIZE 128
u8 flags; /* FOR XPC INTERNAL USE ONLY */ #define XPC_MSG_HDR_MAX_SIZE 16
u8 reserved[7]; /* FOR XPC INTERNAL USE ONLY */ #define XPC_MSG_PAYLOAD_MAX_SIZE (XPC_MSG_MAX_SIZE - XPC_MSG_HDR_MAX_SIZE)
s64 number; /* FOR XPC INTERNAL USE ONLY */
u64 payload; /* user defined portion of message */
};
#define XPC_MSG_PAYLOAD_OFFSET (u64) (&((struct xpc_msg *)0)->payload)
#define XPC_MSG_SIZE(_payload_size) \ #define XPC_MSG_SIZE(_payload_size) \
L1_CACHE_ALIGN(XPC_MSG_PAYLOAD_OFFSET + (_payload_size)) ALIGN(XPC_MSG_HDR_MAX_SIZE + (_payload_size), \
is_uv() ? 64 : 128)
/* /*
* Define the return values and values passed to user's callout functions. * Define the return values and values passed to user's callout functions.
...@@ -210,7 +189,10 @@ enum xp_retval { ...@@ -210,7 +189,10 @@ enum xp_retval {
xpGruCopyError, /* 58: gru_copy_gru() returned error */ xpGruCopyError, /* 58: gru_copy_gru() returned error */
xpGruSendMqError, /* 59: gru send message queue related error */ xpGruSendMqError, /* 59: gru send message queue related error */
xpUnknownReason /* 60: unknown reason - must be last in enum */ xpBadChannelNumber, /* 60: invalid channel number */
xpBadMsgType, /* 60: invalid message type */
xpUnknownReason /* 61: unknown reason - must be last in enum */
}; };
/* /*
...@@ -261,6 +243,9 @@ typedef void (*xpc_channel_func) (enum xp_retval reason, short partid, ...@@ -261,6 +243,9 @@ typedef void (*xpc_channel_func) (enum xp_retval reason, short partid,
* calling xpc_received(). * calling xpc_received().
* *
* All other reason codes indicate failure. * All other reason codes indicate failure.
*
* NOTE: The user defined function must be callable by an interrupt handler
* and thus cannot block.
*/ */
typedef void (*xpc_notify_func) (enum xp_retval reason, short partid, typedef void (*xpc_notify_func) (enum xp_retval reason, short partid,
int ch_number, void *key); int ch_number, void *key);
...@@ -284,7 +269,7 @@ struct xpc_registration { ...@@ -284,7 +269,7 @@ struct xpc_registration {
xpc_channel_func func; /* function to call */ xpc_channel_func func; /* function to call */
void *key; /* pointer to user's key */ void *key; /* pointer to user's key */
u16 nentries; /* #of msg entries in local msg queue */ u16 nentries; /* #of msg entries in local msg queue */
u16 msg_size; /* message queue's message size */ u16 entry_size; /* message queue's message entry size */
u32 assigned_limit; /* limit on #of assigned kthreads */ u32 assigned_limit; /* limit on #of assigned kthreads */
u32 idle_limit; /* limit on #of idle kthreads */ u32 idle_limit; /* limit on #of idle kthreads */
} ____cacheline_aligned; } ____cacheline_aligned;
......
...@@ -154,6 +154,9 @@ xpc_connect(int ch_number, xpc_channel_func func, void *key, u16 payload_size, ...@@ -154,6 +154,9 @@ xpc_connect(int ch_number, xpc_channel_func func, void *key, u16 payload_size,
DBUG_ON(func == NULL); DBUG_ON(func == NULL);
DBUG_ON(assigned_limit == 0 || idle_limit > assigned_limit); DBUG_ON(assigned_limit == 0 || idle_limit > assigned_limit);
if (XPC_MSG_SIZE(payload_size) > XPC_MSG_MAX_SIZE)
return xpPayloadTooBig;
registration = &xpc_registrations[ch_number]; registration = &xpc_registrations[ch_number];
if (mutex_lock_interruptible(&registration->mutex) != 0) if (mutex_lock_interruptible(&registration->mutex) != 0)
...@@ -166,7 +169,7 @@ xpc_connect(int ch_number, xpc_channel_func func, void *key, u16 payload_size, ...@@ -166,7 +169,7 @@ xpc_connect(int ch_number, xpc_channel_func func, void *key, u16 payload_size,
} }
/* register the channel for connection */ /* register the channel for connection */
registration->msg_size = XPC_MSG_SIZE(payload_size); registration->entry_size = XPC_MSG_SIZE(payload_size);
registration->nentries = nentries; registration->nentries = nentries;
registration->assigned_limit = assigned_limit; registration->assigned_limit = assigned_limit;
registration->idle_limit = idle_limit; registration->idle_limit = idle_limit;
...@@ -220,7 +223,7 @@ xpc_disconnect(int ch_number) ...@@ -220,7 +223,7 @@ xpc_disconnect(int ch_number)
registration->func = NULL; registration->func = NULL;
registration->key = NULL; registration->key = NULL;
registration->nentries = 0; registration->nentries = 0;
registration->msg_size = 0; registration->entry_size = 0;
registration->assigned_limit = 0; registration->assigned_limit = 0;
registration->idle_limit = 0; registration->idle_limit = 0;
......
...@@ -181,8 +181,8 @@ struct xpc_vars_part_sn2 { ...@@ -181,8 +181,8 @@ struct xpc_vars_part_sn2 {
xpc_nasid_mask_nlongs)) xpc_nasid_mask_nlongs))
/* /*
* The activate_mq is used to send/receive messages that affect XPC's heartbeat, * The activate_mq is used to send/receive GRU messages that affect XPC's
* partition active state, and channel state. This is UV only. * heartbeat, partition active state, and channel state. This is UV only.
*/ */
struct xpc_activate_mq_msghdr_uv { struct xpc_activate_mq_msghdr_uv {
short partid; /* sender's partid */ short partid; /* sender's partid */
...@@ -209,45 +209,45 @@ struct xpc_activate_mq_msghdr_uv { ...@@ -209,45 +209,45 @@ struct xpc_activate_mq_msghdr_uv {
#define XPC_ACTIVATE_MQ_MSG_MARK_DISENGAGED_UV 11 #define XPC_ACTIVATE_MQ_MSG_MARK_DISENGAGED_UV 11
struct xpc_activate_mq_msg_uv { struct xpc_activate_mq_msg_uv {
struct xpc_activate_mq_msghdr_uv header; struct xpc_activate_mq_msghdr_uv hdr;
}; };
struct xpc_activate_mq_msg_heartbeat_req_uv { struct xpc_activate_mq_msg_heartbeat_req_uv {
struct xpc_activate_mq_msghdr_uv header; struct xpc_activate_mq_msghdr_uv hdr;
u64 heartbeat; u64 heartbeat;
}; };
struct xpc_activate_mq_msg_activate_req_uv { struct xpc_activate_mq_msg_activate_req_uv {
struct xpc_activate_mq_msghdr_uv header; struct xpc_activate_mq_msghdr_uv hdr;
unsigned long rp_gpa; unsigned long rp_gpa;
unsigned long activate_mq_gpa; unsigned long activate_mq_gpa;
}; };
struct xpc_activate_mq_msg_deactivate_req_uv { struct xpc_activate_mq_msg_deactivate_req_uv {
struct xpc_activate_mq_msghdr_uv header; struct xpc_activate_mq_msghdr_uv hdr;
enum xp_retval reason; enum xp_retval reason;
}; };
struct xpc_activate_mq_msg_chctl_closerequest_uv { struct xpc_activate_mq_msg_chctl_closerequest_uv {
struct xpc_activate_mq_msghdr_uv header; struct xpc_activate_mq_msghdr_uv hdr;
short ch_number; short ch_number;
enum xp_retval reason; enum xp_retval reason;
}; };
struct xpc_activate_mq_msg_chctl_closereply_uv { struct xpc_activate_mq_msg_chctl_closereply_uv {
struct xpc_activate_mq_msghdr_uv header; struct xpc_activate_mq_msghdr_uv hdr;
short ch_number; short ch_number;
}; };
struct xpc_activate_mq_msg_chctl_openrequest_uv { struct xpc_activate_mq_msg_chctl_openrequest_uv {
struct xpc_activate_mq_msghdr_uv header; struct xpc_activate_mq_msghdr_uv hdr;
short ch_number; short ch_number;
short msg_size; /* size of notify_mq's messages */ short entry_size; /* size of notify_mq's GRU messages */
short local_nentries; /* ??? Is this needed? What is? */ short local_nentries; /* ??? Is this needed? What is? */
}; };
struct xpc_activate_mq_msg_chctl_openreply_uv { struct xpc_activate_mq_msg_chctl_openreply_uv {
struct xpc_activate_mq_msghdr_uv header; struct xpc_activate_mq_msghdr_uv hdr;
short ch_number; short ch_number;
short remote_nentries; /* ??? Is this needed? What is? */ short remote_nentries; /* ??? Is this needed? What is? */
short local_nentries; /* ??? Is this needed? What is? */ short local_nentries; /* ??? Is this needed? What is? */
...@@ -284,7 +284,7 @@ struct xpc_gp_sn2 { ...@@ -284,7 +284,7 @@ struct xpc_gp_sn2 {
*/ */
struct xpc_openclose_args { struct xpc_openclose_args {
u16 reason; /* reason why channel is closing */ u16 reason; /* reason why channel is closing */
u16 msg_size; /* sizeof each message entry */ u16 entry_size; /* sizeof each message entry */
u16 remote_nentries; /* #of message entries in remote msg queue */ u16 remote_nentries; /* #of message entries in remote msg queue */
u16 local_nentries; /* #of message entries in local msg queue */ u16 local_nentries; /* #of message entries in local msg queue */
unsigned long local_msgqueue_pa; /* phys addr of local message queue */ unsigned long local_msgqueue_pa; /* phys addr of local message queue */
...@@ -294,22 +294,79 @@ struct xpc_openclose_args { ...@@ -294,22 +294,79 @@ struct xpc_openclose_args {
L1_CACHE_ALIGN(sizeof(struct xpc_openclose_args) * \ L1_CACHE_ALIGN(sizeof(struct xpc_openclose_args) * \
XPC_MAX_NCHANNELS) XPC_MAX_NCHANNELS)
/* struct xpc_msg flags */
#define XPC_M_DONE 0x01 /* msg has been received/consumed */ /*
#define XPC_M_READY 0x02 /* msg is ready to be sent */ * Structures to define a fifo singly-linked list.
#define XPC_M_INTERRUPT 0x04 /* send interrupt when msg consumed */ */
struct xpc_fifo_entry_uv {
struct xpc_fifo_entry_uv *next;
};
struct xpc_fifo_head_uv {
struct xpc_fifo_entry_uv *first;
struct xpc_fifo_entry_uv *last;
spinlock_t lock;
int n_entries;
};
/*
* Define a sn2 styled message.
*
* A user-defined message resides in the payload area. The max size of the
* payload is defined by the user via xpc_connect().
*
* The size of a message entry (within a message queue) must be a 128-byte
* cacheline sized multiple in order to facilitate the BTE transfer of messages
* from one message queue to another.
*/
struct xpc_msg_sn2 {
u8 flags; /* FOR XPC INTERNAL USE ONLY */
u8 reserved[7]; /* FOR XPC INTERNAL USE ONLY */
s64 number; /* FOR XPC INTERNAL USE ONLY */
u64 payload; /* user defined portion of message */
};
/* struct xpc_msg_sn2 flags */
#define XPC_M_SN2_DONE 0x01 /* msg has been received/consumed */
#define XPC_M_SN2_READY 0x02 /* msg is ready to be sent */
#define XPC_M_SN2_INTERRUPT 0x04 /* send interrupt when msg consumed */
/*
* The format of a uv XPC notify_mq GRU message is as follows:
*
* A user-defined message resides in the payload area. The max size of the
* payload is defined by the user via xpc_connect().
*
* The size of a message (payload and header) sent via the GRU must be either 1
* or 2 GRU_CACHE_LINE_BYTES in length.
*/
#define XPC_MSG_ADDRESS(_payload) \ struct xpc_notify_mq_msghdr_uv {
((struct xpc_msg *)((u8 *)(_payload) - XPC_MSG_PAYLOAD_OFFSET)) union {
unsigned int gru_msg_hdr; /* FOR GRU INTERNAL USE ONLY */
struct xpc_fifo_entry_uv next; /* FOR XPC INTERNAL USE ONLY */
} u;
short partid; /* FOR XPC INTERNAL USE ONLY */
u8 ch_number; /* FOR XPC INTERNAL USE ONLY */
u8 size; /* FOR XPC INTERNAL USE ONLY */
unsigned int msg_slot_number; /* FOR XPC INTERNAL USE ONLY */
};
struct xpc_notify_mq_msg_uv {
struct xpc_notify_mq_msghdr_uv hdr;
unsigned long payload;
};
/* /*
* Defines notify entry. * Define sn2's notify entry.
* *
* This is used to notify a message's sender that their message was received * This is used to notify a message's sender that their message was received
* and consumed by the intended recipient. * and consumed by the intended recipient.
*/ */
struct xpc_notify { struct xpc_notify_sn2 {
u8 type; /* type of notification */ u8 type; /* type of notification */
/* the following two fields are only used if type == XPC_N_CALL */ /* the following two fields are only used if type == XPC_N_CALL */
...@@ -317,9 +374,20 @@ struct xpc_notify { ...@@ -317,9 +374,20 @@ struct xpc_notify {
void *key; /* pointer to user's key */ void *key; /* pointer to user's key */
}; };
/* struct xpc_notify type of notification */ /* struct xpc_notify_sn2 type of notification */
#define XPC_N_CALL 0x01 /* notify function provided by user */ #define XPC_N_CALL 0x01 /* notify function provided by user */
/*
* Define uv's version of the notify entry. It additionally is used to allocate
* a msg slot on the remote partition into which is copied a sent message.
*/
struct xpc_send_msg_slot_uv {
struct xpc_fifo_entry_uv next;
unsigned int msg_slot_number;
xpc_notify_func func; /* user's notify function */
void *key; /* pointer to user's key */
};
/* /*
* Define the structure that manages all the stuff required by a channel. In * Define the structure that manages all the stuff required by a channel. In
...@@ -409,14 +477,14 @@ struct xpc_channel_sn2 { ...@@ -409,14 +477,14 @@ struct xpc_channel_sn2 {
/* opening or closing of channel */ /* opening or closing of channel */
void *local_msgqueue_base; /* base address of kmalloc'd space */ void *local_msgqueue_base; /* base address of kmalloc'd space */
struct xpc_msg *local_msgqueue; /* local message queue */ struct xpc_msg_sn2 *local_msgqueue; /* local message queue */
void *remote_msgqueue_base; /* base address of kmalloc'd space */ void *remote_msgqueue_base; /* base address of kmalloc'd space */
struct xpc_msg *remote_msgqueue; /* cached copy of remote partition's */ struct xpc_msg_sn2 *remote_msgqueue; /* cached copy of remote */
/* local message queue */ /* partition's local message queue */
unsigned long remote_msgqueue_pa; /* phys addr of remote partition's */ unsigned long remote_msgqueue_pa; /* phys addr of remote partition's */
/* local message queue */ /* local message queue */
struct xpc_notify *notify_queue; /* notify queue for messages sent */ struct xpc_notify_sn2 *notify_queue;/* notify queue for messages sent */
/* various flavors of local and remote Get/Put values */ /* various flavors of local and remote Get/Put values */
...@@ -432,6 +500,12 @@ struct xpc_channel_sn2 { ...@@ -432,6 +500,12 @@ struct xpc_channel_sn2 {
struct xpc_channel_uv { struct xpc_channel_uv {
unsigned long remote_notify_mq_gpa; /* gru phys address of remote */ unsigned long remote_notify_mq_gpa; /* gru phys address of remote */
/* partition's notify mq */ /* partition's notify mq */
struct xpc_send_msg_slot_uv *send_msg_slots;
struct xpc_notify_mq_msg_uv *recv_msg_slots;
struct xpc_fifo_head_uv msg_slot_free_list;
struct xpc_fifo_head_uv recv_msg_list; /* deliverable payloads */
}; };
struct xpc_channel { struct xpc_channel {
...@@ -444,7 +518,7 @@ struct xpc_channel { ...@@ -444,7 +518,7 @@ struct xpc_channel {
u16 number; /* channel # */ u16 number; /* channel # */
u16 msg_size; /* sizeof each msg entry */ u16 entry_size; /* sizeof each msg entry */
u16 local_nentries; /* #of msg entries in local msg queue */ u16 local_nentries; /* #of msg entries in local msg queue */
u16 remote_nentries; /* #of msg entries in remote msg queue */ u16 remote_nentries; /* #of msg entries in remote msg queue */
...@@ -733,8 +807,8 @@ extern enum xp_retval (*xpc_setup_msg_structures) (struct xpc_channel *); ...@@ -733,8 +807,8 @@ extern enum xp_retval (*xpc_setup_msg_structures) (struct xpc_channel *);
extern void (*xpc_teardown_msg_structures) (struct xpc_channel *); extern void (*xpc_teardown_msg_structures) (struct xpc_channel *);
extern void (*xpc_notify_senders_of_disconnect) (struct xpc_channel *); extern void (*xpc_notify_senders_of_disconnect) (struct xpc_channel *);
extern void (*xpc_process_msg_chctl_flags) (struct xpc_partition *, int); extern void (*xpc_process_msg_chctl_flags) (struct xpc_partition *, int);
extern int (*xpc_n_of_deliverable_msgs) (struct xpc_channel *); extern int (*xpc_n_of_deliverable_payloads) (struct xpc_channel *);
extern struct xpc_msg *(*xpc_get_deliverable_msg) (struct xpc_channel *); extern void *(*xpc_get_deliverable_payload) (struct xpc_channel *);
extern void (*xpc_request_partition_activation) (struct xpc_rsvd_page *, extern void (*xpc_request_partition_activation) (struct xpc_rsvd_page *,
unsigned long, int); unsigned long, int);
extern void (*xpc_request_partition_reactivation) (struct xpc_partition *); extern void (*xpc_request_partition_reactivation) (struct xpc_partition *);
...@@ -762,9 +836,9 @@ extern void (*xpc_send_chctl_openreply) (struct xpc_channel *, unsigned long *); ...@@ -762,9 +836,9 @@ extern void (*xpc_send_chctl_openreply) (struct xpc_channel *, unsigned long *);
extern void (*xpc_save_remote_msgqueue_pa) (struct xpc_channel *, extern void (*xpc_save_remote_msgqueue_pa) (struct xpc_channel *,
unsigned long); unsigned long);
extern enum xp_retval (*xpc_send_msg) (struct xpc_channel *, u32, void *, u16, extern enum xp_retval (*xpc_send_payload) (struct xpc_channel *, u32, void *,
u8, xpc_notify_func, void *); u16, u8, xpc_notify_func, void *);
extern void (*xpc_received_msg) (struct xpc_channel *, struct xpc_msg *); extern void (*xpc_received_payload) (struct xpc_channel *, void *);
/* found in xpc_sn2.c */ /* found in xpc_sn2.c */
extern int xpc_init_sn2(void); extern int xpc_init_sn2(void);
...@@ -805,7 +879,7 @@ extern enum xp_retval xpc_initiate_send_notify(short, int, u32, void *, u16, ...@@ -805,7 +879,7 @@ extern enum xp_retval xpc_initiate_send_notify(short, int, u32, void *, u16,
extern void xpc_initiate_received(short, int, void *); extern void xpc_initiate_received(short, int, void *);
extern void xpc_process_sent_chctl_flags(struct xpc_partition *); extern void xpc_process_sent_chctl_flags(struct xpc_partition *);
extern void xpc_connected_callout(struct xpc_channel *); extern void xpc_connected_callout(struct xpc_channel *);
extern void xpc_deliver_msg(struct xpc_channel *); extern void xpc_deliver_payload(struct xpc_channel *);
extern void xpc_disconnect_channel(const int, struct xpc_channel *, extern void xpc_disconnect_channel(const int, struct xpc_channel *,
enum xp_retval, unsigned long *); enum xp_retval, unsigned long *);
extern void xpc_disconnect_callout(struct xpc_channel *, enum xp_retval); extern void xpc_disconnect_callout(struct xpc_channel *, enum xp_retval);
......
...@@ -139,7 +139,7 @@ xpc_process_disconnect(struct xpc_channel *ch, unsigned long *irq_flags) ...@@ -139,7 +139,7 @@ xpc_process_disconnect(struct xpc_channel *ch, unsigned long *irq_flags)
ch->func = NULL; ch->func = NULL;
ch->key = NULL; ch->key = NULL;
ch->msg_size = 0; ch->entry_size = 0;
ch->local_nentries = 0; ch->local_nentries = 0;
ch->remote_nentries = 0; ch->remote_nentries = 0;
ch->kthreads_assigned_limit = 0; ch->kthreads_assigned_limit = 0;
...@@ -315,9 +315,9 @@ again: ...@@ -315,9 +315,9 @@ again:
if (chctl_flags & XPC_CHCTL_OPENREQUEST) { if (chctl_flags & XPC_CHCTL_OPENREQUEST) {
dev_dbg(xpc_chan, "XPC_CHCTL_OPENREQUEST (msg_size=%d, " dev_dbg(xpc_chan, "XPC_CHCTL_OPENREQUEST (entry_size=%d, "
"local_nentries=%d) received from partid=%d, " "local_nentries=%d) received from partid=%d, "
"channel=%d\n", args->msg_size, args->local_nentries, "channel=%d\n", args->entry_size, args->local_nentries,
ch->partid, ch->number); ch->partid, ch->number);
if (part->act_state == XPC_P_AS_DEACTIVATING || if (part->act_state == XPC_P_AS_DEACTIVATING ||
...@@ -338,10 +338,10 @@ again: ...@@ -338,10 +338,10 @@ again:
/* /*
* The meaningful OPENREQUEST connection state fields are: * The meaningful OPENREQUEST connection state fields are:
* msg_size = size of channel's messages in bytes * entry_size = size of channel's messages in bytes
* local_nentries = remote partition's local_nentries * local_nentries = remote partition's local_nentries
*/ */
if (args->msg_size == 0 || args->local_nentries == 0) { if (args->entry_size == 0 || args->local_nentries == 0) {
/* assume OPENREQUEST was delayed by mistake */ /* assume OPENREQUEST was delayed by mistake */
spin_unlock_irqrestore(&ch->lock, irq_flags); spin_unlock_irqrestore(&ch->lock, irq_flags);
return; return;
...@@ -351,14 +351,14 @@ again: ...@@ -351,14 +351,14 @@ again:
ch->remote_nentries = args->local_nentries; ch->remote_nentries = args->local_nentries;
if (ch->flags & XPC_C_OPENREQUEST) { if (ch->flags & XPC_C_OPENREQUEST) {
if (args->msg_size != ch->msg_size) { if (args->entry_size != ch->entry_size) {
XPC_DISCONNECT_CHANNEL(ch, xpUnequalMsgSizes, XPC_DISCONNECT_CHANNEL(ch, xpUnequalMsgSizes,
&irq_flags); &irq_flags);
spin_unlock_irqrestore(&ch->lock, irq_flags); spin_unlock_irqrestore(&ch->lock, irq_flags);
return; return;
} }
} else { } else {
ch->msg_size = args->msg_size; ch->entry_size = args->entry_size;
XPC_SET_REASON(ch, 0, 0); XPC_SET_REASON(ch, 0, 0);
ch->flags &= ~XPC_C_DISCONNECTED; ch->flags &= ~XPC_C_DISCONNECTED;
...@@ -473,7 +473,7 @@ xpc_connect_channel(struct xpc_channel *ch) ...@@ -473,7 +473,7 @@ xpc_connect_channel(struct xpc_channel *ch)
ch->local_nentries = registration->nentries; ch->local_nentries = registration->nentries;
if (ch->flags & XPC_C_ROPENREQUEST) { if (ch->flags & XPC_C_ROPENREQUEST) {
if (registration->msg_size != ch->msg_size) { if (registration->entry_size != ch->entry_size) {
/* the local and remote sides aren't the same */ /* the local and remote sides aren't the same */
/* /*
...@@ -492,7 +492,7 @@ xpc_connect_channel(struct xpc_channel *ch) ...@@ -492,7 +492,7 @@ xpc_connect_channel(struct xpc_channel *ch)
return xpUnequalMsgSizes; return xpUnequalMsgSizes;
} }
} else { } else {
ch->msg_size = registration->msg_size; ch->entry_size = registration->entry_size;
XPC_SET_REASON(ch, 0, 0); XPC_SET_REASON(ch, 0, 0);
ch->flags &= ~XPC_C_DISCONNECTED; ch->flags &= ~XPC_C_DISCONNECTED;
...@@ -859,8 +859,8 @@ xpc_initiate_send(short partid, int ch_number, u32 flags, void *payload, ...@@ -859,8 +859,8 @@ xpc_initiate_send(short partid, int ch_number, u32 flags, void *payload,
DBUG_ON(payload == NULL); DBUG_ON(payload == NULL);
if (xpc_part_ref(part)) { if (xpc_part_ref(part)) {
ret = xpc_send_msg(&part->channels[ch_number], flags, payload, ret = xpc_send_payload(&part->channels[ch_number], flags,
payload_size, 0, NULL, NULL); payload, payload_size, 0, NULL, NULL);
xpc_part_deref(part); xpc_part_deref(part);
} }
...@@ -911,23 +911,24 @@ xpc_initiate_send_notify(short partid, int ch_number, u32 flags, void *payload, ...@@ -911,23 +911,24 @@ xpc_initiate_send_notify(short partid, int ch_number, u32 flags, void *payload,
DBUG_ON(func == NULL); DBUG_ON(func == NULL);
if (xpc_part_ref(part)) { if (xpc_part_ref(part)) {
ret = xpc_send_msg(&part->channels[ch_number], flags, payload, ret = xpc_send_payload(&part->channels[ch_number], flags,
payload_size, XPC_N_CALL, func, key); payload, payload_size, XPC_N_CALL, func,
key);
xpc_part_deref(part); xpc_part_deref(part);
} }
return ret; return ret;
} }
/* /*
* Deliver a message to its intended recipient. * Deliver a message's payload to its intended recipient.
*/ */
void void
xpc_deliver_msg(struct xpc_channel *ch) xpc_deliver_payload(struct xpc_channel *ch)
{ {
struct xpc_msg *msg; void *payload;
msg = xpc_get_deliverable_msg(ch); payload = xpc_get_deliverable_payload(ch);
if (msg != NULL) { if (payload != NULL) {
/* /*
* This ref is taken to protect the payload itself from being * This ref is taken to protect the payload itself from being
...@@ -939,18 +940,16 @@ xpc_deliver_msg(struct xpc_channel *ch) ...@@ -939,18 +940,16 @@ xpc_deliver_msg(struct xpc_channel *ch)
atomic_inc(&ch->kthreads_active); atomic_inc(&ch->kthreads_active);
if (ch->func != NULL) { if (ch->func != NULL) {
dev_dbg(xpc_chan, "ch->func() called, msg=0x%p, " dev_dbg(xpc_chan, "ch->func() called, payload=0x%p "
"msg_number=%ld, partid=%d, channel=%d\n", "partid=%d channel=%d\n", payload, ch->partid,
msg, (signed long)msg->number, ch->partid,
ch->number); ch->number);
/* deliver the message to its intended recipient */ /* deliver the message to its intended recipient */
ch->func(xpMsgReceived, ch->partid, ch->number, ch->func(xpMsgReceived, ch->partid, ch->number, payload,
&msg->payload, ch->key); ch->key);
dev_dbg(xpc_chan, "ch->func() returned, msg=0x%p, " dev_dbg(xpc_chan, "ch->func() returned, payload=0x%p "
"msg_number=%ld, partid=%d, channel=%d\n", "partid=%d channel=%d\n", payload, ch->partid,
msg, (signed long)msg->number, ch->partid,
ch->number); ch->number);
} }
...@@ -959,14 +958,11 @@ xpc_deliver_msg(struct xpc_channel *ch) ...@@ -959,14 +958,11 @@ xpc_deliver_msg(struct xpc_channel *ch)
} }
/* /*
* Acknowledge receipt of a delivered message. * Acknowledge receipt of a delivered message's payload.
*
* If a message has XPC_M_INTERRUPT set, send an interrupt to the partition
* that sent the message.
* *
* This function, although called by users, does not call xpc_part_ref() to * This function, although called by users, does not call xpc_part_ref() to
* ensure that the partition infrastructure is in place. It relies on the * ensure that the partition infrastructure is in place. It relies on the
* fact that we called xpc_msgqueue_ref() in xpc_deliver_msg(). * fact that we called xpc_msgqueue_ref() in xpc_deliver_payload().
* *
* Arguments: * Arguments:
* *
...@@ -980,14 +976,13 @@ xpc_initiate_received(short partid, int ch_number, void *payload) ...@@ -980,14 +976,13 @@ xpc_initiate_received(short partid, int ch_number, void *payload)
{ {
struct xpc_partition *part = &xpc_partitions[partid]; struct xpc_partition *part = &xpc_partitions[partid];
struct xpc_channel *ch; struct xpc_channel *ch;
struct xpc_msg *msg = XPC_MSG_ADDRESS(payload);
DBUG_ON(partid < 0 || partid >= xp_max_npartitions); DBUG_ON(partid < 0 || partid >= xp_max_npartitions);
DBUG_ON(ch_number < 0 || ch_number >= part->nchannels); DBUG_ON(ch_number < 0 || ch_number >= part->nchannels);
ch = &part->channels[ch_number]; ch = &part->channels[ch_number];
xpc_received_msg(ch, msg); xpc_received_payload(ch, payload);
/* the call to xpc_msgqueue_ref() was done by xpc_deliver_msg() */ /* the call to xpc_msgqueue_ref() was done by xpc_deliver_payload() */
xpc_msgqueue_deref(ch); xpc_msgqueue_deref(ch);
} }
...@@ -188,8 +188,8 @@ u64 (*xpc_get_chctl_all_flags) (struct xpc_partition *part); ...@@ -188,8 +188,8 @@ u64 (*xpc_get_chctl_all_flags) (struct xpc_partition *part);
enum xp_retval (*xpc_setup_msg_structures) (struct xpc_channel *ch); enum xp_retval (*xpc_setup_msg_structures) (struct xpc_channel *ch);
void (*xpc_teardown_msg_structures) (struct xpc_channel *ch); void (*xpc_teardown_msg_structures) (struct xpc_channel *ch);
void (*xpc_process_msg_chctl_flags) (struct xpc_partition *part, int ch_number); void (*xpc_process_msg_chctl_flags) (struct xpc_partition *part, int ch_number);
int (*xpc_n_of_deliverable_msgs) (struct xpc_channel *ch); int (*xpc_n_of_deliverable_payloads) (struct xpc_channel *ch);
struct xpc_msg *(*xpc_get_deliverable_msg) (struct xpc_channel *ch); void *(*xpc_get_deliverable_payload) (struct xpc_channel *ch);
void (*xpc_request_partition_activation) (struct xpc_rsvd_page *remote_rp, void (*xpc_request_partition_activation) (struct xpc_rsvd_page *remote_rp,
unsigned long remote_rp_pa, unsigned long remote_rp_pa,
...@@ -220,10 +220,11 @@ void (*xpc_send_chctl_openreply) (struct xpc_channel *ch, ...@@ -220,10 +220,11 @@ void (*xpc_send_chctl_openreply) (struct xpc_channel *ch,
void (*xpc_save_remote_msgqueue_pa) (struct xpc_channel *ch, void (*xpc_save_remote_msgqueue_pa) (struct xpc_channel *ch,
unsigned long msgqueue_pa); unsigned long msgqueue_pa);
enum xp_retval (*xpc_send_msg) (struct xpc_channel *ch, u32 flags, enum xp_retval (*xpc_send_payload) (struct xpc_channel *ch, u32 flags,
void *payload, u16 payload_size, u8 notify_type, void *payload, u16 payload_size,
xpc_notify_func func, void *key); u8 notify_type, xpc_notify_func func,
void (*xpc_received_msg) (struct xpc_channel *ch, struct xpc_msg *msg); void *key);
void (*xpc_received_payload) (struct xpc_channel *ch, void *payload);
/* /*
* Timer function to enforce the timelimit on the partition disengage. * Timer function to enforce the timelimit on the partition disengage.
...@@ -714,9 +715,9 @@ xpc_kthread_waitmsgs(struct xpc_partition *part, struct xpc_channel *ch) ...@@ -714,9 +715,9 @@ xpc_kthread_waitmsgs(struct xpc_partition *part, struct xpc_channel *ch)
do { do {
/* deliver messages to their intended recipients */ /* deliver messages to their intended recipients */
while (xpc_n_of_deliverable_msgs(ch) > 0 && while (xpc_n_of_deliverable_payloads(ch) > 0 &&
!(ch->flags & XPC_C_DISCONNECTING)) { !(ch->flags & XPC_C_DISCONNECTING)) {
xpc_deliver_msg(ch); xpc_deliver_payload(ch);
} }
if (atomic_inc_return(&ch->kthreads_idle) > if (atomic_inc_return(&ch->kthreads_idle) >
...@@ -730,7 +731,7 @@ xpc_kthread_waitmsgs(struct xpc_partition *part, struct xpc_channel *ch) ...@@ -730,7 +731,7 @@ xpc_kthread_waitmsgs(struct xpc_partition *part, struct xpc_channel *ch)
"wait_event_interruptible_exclusive()\n"); "wait_event_interruptible_exclusive()\n");
(void)wait_event_interruptible_exclusive(ch->idle_wq, (void)wait_event_interruptible_exclusive(ch->idle_wq,
(xpc_n_of_deliverable_msgs(ch) > 0 || (xpc_n_of_deliverable_payloads(ch) > 0 ||
(ch->flags & XPC_C_DISCONNECTING))); (ch->flags & XPC_C_DISCONNECTING)));
atomic_dec(&ch->kthreads_idle); atomic_dec(&ch->kthreads_idle);
...@@ -775,7 +776,7 @@ xpc_kthread_start(void *args) ...@@ -775,7 +776,7 @@ xpc_kthread_start(void *args)
* additional kthreads to help deliver them. We only * additional kthreads to help deliver them. We only
* need one less than total #of messages to deliver. * need one less than total #of messages to deliver.
*/ */
n_needed = xpc_n_of_deliverable_msgs(ch) - 1; n_needed = xpc_n_of_deliverable_payloads(ch) - 1;
if (n_needed > 0 && !(ch->flags & XPC_C_DISCONNECTING)) if (n_needed > 0 && !(ch->flags & XPC_C_DISCONNECTING))
xpc_activate_kthreads(ch, n_needed); xpc_activate_kthreads(ch, n_needed);
......
This diff is collapsed.
This diff is collapsed.
...@@ -57,11 +57,10 @@ struct xpnet_message { ...@@ -57,11 +57,10 @@ struct xpnet_message {
* *
* XPC expects each message to exist in an individual cacheline. * XPC expects each message to exist in an individual cacheline.
*/ */
#define XPNET_MSG_SIZE (L1_CACHE_BYTES - XPC_MSG_PAYLOAD_OFFSET) #define XPNET_MSG_SIZE XPC_MSG_PAYLOAD_MAX_SIZE
#define XPNET_MSG_DATA_MAX \ #define XPNET_MSG_DATA_MAX \
(XPNET_MSG_SIZE - (u64)(&((struct xpnet_message *)0)->data)) (XPNET_MSG_SIZE - offsetof(struct xpnet_message, data))
#define XPNET_MSG_ALIGNED_SIZE (L1_CACHE_ALIGN(XPNET_MSG_SIZE)) #define XPNET_MSG_NENTRIES (PAGE_SIZE / XPC_MSG_MAX_SIZE)
#define XPNET_MSG_NENTRIES (PAGE_SIZE / XPNET_MSG_ALIGNED_SIZE)
#define XPNET_MAX_KTHREADS (XPNET_MSG_NENTRIES + 1) #define XPNET_MAX_KTHREADS (XPNET_MSG_NENTRIES + 1)
#define XPNET_MAX_IDLE_KTHREADS (XPNET_MSG_NENTRIES + 1) #define XPNET_MAX_IDLE_KTHREADS (XPNET_MSG_NENTRIES + 1)
...@@ -408,6 +407,7 @@ xpnet_send(struct sk_buff *skb, struct xpnet_pending_msg *queued_msg, ...@@ -408,6 +407,7 @@ xpnet_send(struct sk_buff *skb, struct xpnet_pending_msg *queued_msg,
{ {
u8 msg_buffer[XPNET_MSG_SIZE]; u8 msg_buffer[XPNET_MSG_SIZE];
struct xpnet_message *msg = (struct xpnet_message *)&msg_buffer; struct xpnet_message *msg = (struct xpnet_message *)&msg_buffer;
u16 msg_size = sizeof(struct xpnet_message);
enum xp_retval ret; enum xp_retval ret;
msg->embedded_bytes = embedded_bytes; msg->embedded_bytes = embedded_bytes;
...@@ -417,6 +417,7 @@ xpnet_send(struct sk_buff *skb, struct xpnet_pending_msg *queued_msg, ...@@ -417,6 +417,7 @@ xpnet_send(struct sk_buff *skb, struct xpnet_pending_msg *queued_msg,
&msg->data, skb->data, (size_t)embedded_bytes); &msg->data, skb->data, (size_t)embedded_bytes);
skb_copy_from_linear_data(skb, &msg->data, skb_copy_from_linear_data(skb, &msg->data,
(size_t)embedded_bytes); (size_t)embedded_bytes);
msg_size += embedded_bytes - 1;
} else { } else {
msg->version = XPNET_VERSION; msg->version = XPNET_VERSION;
} }
...@@ -435,7 +436,7 @@ xpnet_send(struct sk_buff *skb, struct xpnet_pending_msg *queued_msg, ...@@ -435,7 +436,7 @@ xpnet_send(struct sk_buff *skb, struct xpnet_pending_msg *queued_msg,
atomic_inc(&queued_msg->use_count); atomic_inc(&queued_msg->use_count);
ret = xpc_send_notify(dest_partid, XPC_NET_CHANNEL, XPC_NOWAIT, msg, ret = xpc_send_notify(dest_partid, XPC_NET_CHANNEL, XPC_NOWAIT, msg,
XPNET_MSG_SIZE, xpnet_send_completed, queued_msg); msg_size, xpnet_send_completed, queued_msg);
if (unlikely(ret != xpSuccess)) if (unlikely(ret != xpSuccess))
atomic_dec(&queued_msg->use_count); atomic_dec(&queued_msg->use_count);
} }
......
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