Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
--- a/devices/rtdmnet.c Mon Oct 01 18:55:06 2018 +0200
+++ b/devices/rtdmnet.c Mon Oct 01 19:54:54 2018 +0200
@@ -43,9 +43,10 @@
#include <linux/etherdevice.h>
#include <rtdm/rtdm.h>
-// for rtnetif_carrier_ok
+// for rtnetif_carrier_ok and rtpc_dispatch_call
// This needs -I@XENOMAI_DIR@/kernel/drivers/net/stack/include in Kbuild.in
#include <rtnet_port.h>
+#include <rtnet_rtpc.h>
#include "../globals.h"
#include "ecdev.h"
@@ -302,6 +303,32 @@
/*****************************************************************************/
+// delegate to some rtdm thread when called from nrt context
+struct sendmsg_params {
+ int socket;
+ struct user_msghdr *msg;
+};
+
+static int sendmsg_handler(struct rt_proc_call *call)
+{
+ struct sendmsg_params *params;
+
+ params = rtpc_get_priv(call, struct sendmsg_params);
+
+ return rtdm_sendmsg(params->socket, params->msg, 0);
+}
+
+static ssize_t
+nrt_rtdm_sendmsg(int socket, struct user_msghdr *msg)
+{
+ int ret;
+ struct sendmsg_params params = {socket, msg};
+
+ ret = rtpc_dispatch_call(sendmsg_handler, 0, ¶ms,
+ sizeof(params), NULL, NULL);
+ return ret;
+}
+
int ec_gen_device_start_xmit(
ec_gen_device_t *dev,
struct sk_buff *skb
@@ -323,7 +350,10 @@
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
- ret = rtdm_sendmsg(dev->socket, &msg, 0);
+ if (ipipe_root_p)
+ ret = nrt_rtdm_sendmsg(dev->socket, &msg);
+ else
+ ret = rtdm_sendmsg(dev->socket, &msg, 0);
return ret == len ? NETDEV_TX_OK : NETDEV_TX_BUSY;
}
@@ -332,6 +362,33 @@
/** Polls the device.
*/
+
+// delegate to some rtdm thread when called from nrt context
+struct recvmsg_params {
+ int socket;
+ struct user_msghdr *msg;
+};
+
+static int recvmsg_handler(struct rt_proc_call *call)
+{
+ struct recvmsg_params *params;
+
+ params = rtpc_get_priv(call, struct recvmsg_params);
+
+ return rtdm_recvmsg(params->socket, params->msg, MSG_DONTWAIT);
+}
+
+static ssize_t
+nrt_rtdm_recvmsg(int socket, struct user_msghdr *msg)
+{
+ int ret;
+ struct recvmsg_params params = {socket,msg};
+
+ ret = rtpc_dispatch_call(recvmsg_handler, 0, ¶ms,
+ sizeof(params), NULL, NULL);
+ return ret;
+}
+
void ec_gen_device_poll(
ec_gen_device_t *dev
)
@@ -349,7 +406,11 @@
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
- ret = rtdm_recvmsg(dev->socket, &msg, MSG_DONTWAIT);
+ if (ipipe_root_p)
+ ret = nrt_rtdm_recvmsg(dev->socket, &msg);
+ else
+ ret = rtdm_recvmsg(dev->socket, &msg, MSG_DONTWAIT);
+
if (ret > 0) {
ecdev_receive(dev->ecdev, dev->rx_buf, ret);
} else if (ret < 0) {