devices/rtdmnet.c
author Edouard Tisserant <edouard.tisserant@gmail.com>
Fri, 05 Oct 2018 01:26:51 +0200
branchstable-1.5
changeset 2719 94c9657e0bee
parent 2718 137cdf41bcec
child 2722 5e5bec5ee9c1
permissions -rw-r--r--
Xenomai 2 to 3 migration says "RTDM drivers implementing differentiated ioctl() support for both domains should serve all real-time only requests from ioctl_rt(), returning -ENOSYS for any unrecognized request, which will cause the adaptive switch to take place automatically to the ioctl_nrt() handler. The ioctl_nrt() should then implement all requests which may be valid from the regular Linux domain exclusively."
2709
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     1
/******************************************************************************
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     2
 *
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     3
 *  $Id$
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     4
 *
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     5
 *  Copyright (C) 2006-2008  Florian Pose, Ingenieurgemeinschaft IgH
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     6
 *  Copyright (C) 2014-2018  Edouard Tisserant
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     7
 *
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     8
 *  This file is part of the IgH EtherCAT Master.
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     9
 *
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    10
 *  The IgH EtherCAT Master is free software; you can redistribute it and/or
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    11
 *  modify it under the terms of the GNU General Public License version 2, as
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    12
 *  published by the Free Software Foundation.
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    13
 *
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    14
 *  The IgH EtherCAT Master is distributed in the hope that it will be useful,
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    17
 *  Public License for more details.
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    18
 *
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    19
 *  You should have received a copy of the GNU General Public License along
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    20
 *  with the IgH EtherCAT Master; if not, write to the Free Software
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    21
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    22
 *
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    23
 *  ---
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    24
 *
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    25
 *  The license mentioned above concerns the source code only. Using the
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    26
 *  EtherCAT technology and brand is only permitted in compliance with the
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    27
 *  industrial property and similar rights of Beckhoff Automation GmbH.
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    28
 *
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    29
 *****************************************************************************/
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    30
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    31
/** \file
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    32
 * EtherCAT generic Xenomai's RTDM RAW Ethernet socket device module.
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    33
 * Heavily based on generic.c. Should be merged in a single file with #ifdefs
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    34
 */
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    35
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    36
/*****************************************************************************/
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    37
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    38
#include <linux/module.h>
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    39
#include <linux/device.h>
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    40
#include <linux/err.h>
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    41
#include <linux/version.h>
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    42
#include <linux/if_arp.h> /* ARPHRD_ETHER */
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    43
#include <linux/etherdevice.h>
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    44
#include <rtdm/rtdm.h>
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    45
2717
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
    46
// for rtnetif_carrier_ok and rtpc_dispatch_call
2709
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    47
// This needs -I@XENOMAI_DIR@/kernel/drivers/net/stack/include in Kbuild.in
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    48
#include <rtnet_port.h>
2717
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
    49
#include <rtnet_rtpc.h>
2709
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    50
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    51
#include "../globals.h"
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    52
#include "ecdev.h"
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    53
2711
a5c4ccc02285 Fixed rtdmnet.c PFX and removed useless commented code.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2709
diff changeset
    54
#define PFX "ec_rtdmnet: "
2709
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    55
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    56
#define ETH_P_ETHERCAT 0x88A4
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    57
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    58
#define EC_GEN_RX_BUF_SIZE 1600
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    59
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    60
/*****************************************************************************/
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    61
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    62
int __init ec_gen_init_module(void);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    63
void __exit ec_gen_cleanup_module(void);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    64
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    65
/*****************************************************************************/
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    66
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    67
/** \cond */
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    68
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    69
MODULE_AUTHOR("Edouard Tisserant <edouard.tisserant@gmail.com>");
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    70
MODULE_DESCRIPTION("EtherCAT generic Xenomai's RTDM RAW Ethernet socket device module.");
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    71
MODULE_LICENSE("GPL");
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    72
MODULE_VERSION(EC_MASTER_VERSION);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    73
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    74
/** \endcond */
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    75
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    76
struct list_head generic_devices;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    77
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    78
typedef struct {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    79
    struct list_head list;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    80
    struct net_device *netdev;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    81
    struct rtnet_device *used_netdev;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    82
    int socket;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    83
    ec_device_t *ecdev;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    84
    uint8_t *rx_buf;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    85
    // struct sockaddr_ll dest_addr;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    86
} ec_gen_device_t;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    87
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    88
typedef struct {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    89
    struct list_head list;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    90
    struct rtnet_device *netdev;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    91
    char name[IFNAMSIZ];
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    92
    int ifindex;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    93
    uint8_t dev_addr[ETH_ALEN];
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    94
} ec_gen_interface_desc_t;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    95
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    96
int ec_gen_device_open(ec_gen_device_t *);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    97
int ec_gen_device_stop(ec_gen_device_t *);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    98
int ec_gen_device_start_xmit(ec_gen_device_t *, struct sk_buff *);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    99
void ec_gen_device_poll(ec_gen_device_t *);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   100
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   101
/*****************************************************************************/
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   102
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   103
static int ec_gen_netdev_open(struct net_device *dev)
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   104
{
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   105
    ec_gen_device_t *gendev = *((ec_gen_device_t **) netdev_priv(dev));
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   106
    return ec_gen_device_open(gendev);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   107
}
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   108
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   109
/*****************************************************************************/
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   110
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   111
static int ec_gen_netdev_stop(struct net_device *dev)
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   112
{
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   113
    ec_gen_device_t *gendev = *((ec_gen_device_t **) netdev_priv(dev));
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   114
    return ec_gen_device_stop(gendev);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   115
}
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   116
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   117
/*****************************************************************************/
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   118
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   119
static int ec_gen_netdev_start_xmit(
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   120
        struct sk_buff *skb,
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   121
        struct net_device *dev
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   122
        )
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   123
{
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   124
    ec_gen_device_t *gendev = *((ec_gen_device_t **) netdev_priv(dev));
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   125
    return ec_gen_device_start_xmit(gendev, skb);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   126
}
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   127
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   128
/*****************************************************************************/
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   129
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   130
void ec_gen_poll(struct net_device *dev)
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   131
{
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   132
    ec_gen_device_t *gendev = *((ec_gen_device_t **) netdev_priv(dev));
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   133
    ec_gen_device_poll(gendev);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   134
}
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   135
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   136
/*****************************************************************************/
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   137
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   138
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   139
static const struct net_device_ops ec_gen_netdev_ops = {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   140
    .ndo_open       = ec_gen_netdev_open,
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   141
    .ndo_stop       = ec_gen_netdev_stop,
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   142
    .ndo_start_xmit = ec_gen_netdev_start_xmit,
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   143
};
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   144
#endif
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   145
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   146
/*****************************************************************************/
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   147
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   148
/** Init generic device.
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   149
 */
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   150
int ec_gen_device_init(
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   151
        ec_gen_device_t *dev
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   152
        )
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   153
{
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   154
    ec_gen_device_t **priv;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   155
    char null = 0x00;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   156
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   157
    dev->ecdev = NULL;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   158
    dev->socket = -1;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   159
    dev->rx_buf = NULL;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   160
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   161
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   162
    dev->netdev = alloc_netdev(sizeof(ec_gen_device_t *), &null,
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   163
            NET_NAME_UNKNOWN, ether_setup);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   164
#else
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   165
    dev->netdev = alloc_netdev(sizeof(ec_gen_device_t *), &null, ether_setup);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   166
#endif
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   167
    if (!dev->netdev) {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   168
        return -ENOMEM;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   169
    }
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   170
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   171
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   172
    dev->netdev->netdev_ops = &ec_gen_netdev_ops;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   173
#else
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   174
    dev->netdev->open = ec_gen_netdev_open;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   175
    dev->netdev->stop = ec_gen_netdev_stop;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   176
    dev->netdev->hard_start_xmit = ec_gen_netdev_start_xmit;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   177
#endif
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   178
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   179
    priv = netdev_priv(dev->netdev);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   180
    *priv = dev;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   181
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   182
    return 0;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   183
}
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   184
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   185
/*****************************************************************************/
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   186
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   187
/** Clear generic device.
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   188
 */
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   189
void ec_gen_device_clear(
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   190
        ec_gen_device_t *dev
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   191
        )
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   192
{
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   193
    if (dev->ecdev) {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   194
        ecdev_close(dev->ecdev);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   195
        ecdev_withdraw(dev->ecdev);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   196
    }
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   197
    if (!(dev->socket < 0)) {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   198
        rtdm_close(dev->socket);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   199
        dev->socket = -1;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   200
    }
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   201
    free_netdev(dev->netdev);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   202
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   203
    if (dev->rx_buf) {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   204
        kfree(dev->rx_buf);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   205
    }
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   206
}
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   207
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   208
/*****************************************************************************/
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   209
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   210
/** Creates a network socket.
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   211
 */
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   212
int ec_gen_device_create_socket(
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   213
        ec_gen_device_t *dev,
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   214
        ec_gen_interface_desc_t *desc
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   215
        )
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   216
{
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   217
    int ret;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   218
    struct sockaddr_ll sa;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   219
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   220
    dev->rx_buf = kmalloc(EC_GEN_RX_BUF_SIZE, GFP_KERNEL);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   221
    if (!dev->rx_buf) {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   222
        return -ENOMEM;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   223
    }
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   224
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   225
    /* create rt-socket */
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   226
    dev->socket = rtdm_socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ETHERCAT));
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   227
    if (dev->socket < 0) {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   228
        printk(" rtdm_socket() = %d!\n", dev->socket);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   229
        return dev->socket;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   230
    }
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   231
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   232
    printk(KERN_ERR PFX "Binding socket to interface %i (%s).\n",
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   233
            desc->ifindex, desc->name);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   234
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   235
    memset(&sa, 0x00, sizeof(sa));
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   236
    sa.sll_family = AF_PACKET;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   237
    sa.sll_protocol = htons(ETH_P_ETHERCAT);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   238
    sa.sll_ifindex = desc->ifindex;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   239
    ret = rtdm_bind(dev->socket, (struct sockaddr *)&sa,
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   240
                      sizeof(struct sockaddr_ll));
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   241
    if (ret < 0) {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   242
        printk(" rtdm_bind() = %d!\n", ret);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   243
        rtdm_close(dev->socket);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   244
        dev->socket = -1;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   245
        return ret;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   246
    }
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   247
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   248
    return 0;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   249
}
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   250
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   251
/*****************************************************************************/
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   252
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   253
/** Offer generic device to master.
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   254
 */
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   255
int ec_gen_device_offer(
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   256
        ec_gen_device_t *dev,
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   257
        ec_gen_interface_desc_t *desc
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   258
        )
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   259
{
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   260
    int ret = 0;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   261
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   262
    dev->used_netdev = desc->netdev;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   263
    memcpy(dev->netdev->dev_addr, desc->dev_addr, ETH_ALEN);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   264
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   265
    dev->ecdev = ecdev_offer(dev->netdev, ec_gen_poll, THIS_MODULE);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   266
    if (dev->ecdev) {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   267
        if (ec_gen_device_create_socket(dev, desc)) {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   268
            ecdev_withdraw(dev->ecdev);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   269
            dev->ecdev = NULL;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   270
        } else if (ecdev_open(dev->ecdev)) {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   271
            ecdev_withdraw(dev->ecdev);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   272
            dev->ecdev = NULL;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   273
        } else {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   274
            ecdev_set_link(dev->ecdev, rtnetif_carrier_ok(dev->used_netdev)); // FIXME
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   275
            ret = 1;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   276
        }
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   277
    }
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   278
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   279
    return ret;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   280
}
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   281
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   282
/*****************************************************************************/
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   283
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   284
/** Open the device.
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   285
 */
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   286
int ec_gen_device_open(
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   287
        ec_gen_device_t *dev
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   288
        )
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   289
{
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   290
    return 0;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   291
}
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   292
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   293
/*****************************************************************************/
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   294
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   295
/** Stop the device.
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   296
 */
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   297
int ec_gen_device_stop(
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   298
        ec_gen_device_t *dev
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   299
        )
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   300
{
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   301
    return 0;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   302
}
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   303
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   304
/*****************************************************************************/
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   305
2717
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   306
// delegate to some rtdm thread when called from nrt context
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   307
struct sendmsg_params {
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   308
    int socket;
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   309
    struct user_msghdr *msg;
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   310
};
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   311
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   312
static int sendmsg_handler(struct rt_proc_call *call)
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   313
{
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   314
    struct sendmsg_params *params;
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   315
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   316
    params = rtpc_get_priv(call, struct sendmsg_params);
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   317
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   318
    return rtdm_sendmsg(params->socket, params->msg, 0);
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   319
}
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   320
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   321
static ssize_t
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   322
nrt_rtdm_sendmsg(int socket, struct user_msghdr *msg)
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   323
{
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   324
    int ret;
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   325
    struct sendmsg_params params = {socket, msg};
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   326
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   327
    ret = rtpc_dispatch_call(sendmsg_handler, 0, &params,
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   328
                             sizeof(params), NULL, NULL);
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   329
    return ret;
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   330
}
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   331
2709
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   332
int ec_gen_device_start_xmit(
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   333
        ec_gen_device_t *dev,
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   334
        struct sk_buff *skb
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   335
        )
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   336
{
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   337
    struct user_msghdr msg;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   338
    struct iovec iov;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   339
    size_t len = skb->len;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   340
    int ret;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   341
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   342
    ecdev_set_link(dev->ecdev, rtnetif_carrier_ok(dev->used_netdev));
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   343
    //ecdev_set_link(dev->ecdev, 1); // FIXME
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   344
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   345
    iov.iov_base = skb->data;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   346
    iov.iov_len = len;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   347
    memset(&msg, 0, sizeof(msg));
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   348
    // msg.msg_name    = &dev->dest_addr;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   349
    // msg.msg_namelen = sizeof(dev->dest_addr);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   350
    msg.msg_iov     = &iov;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   351
    msg.msg_iovlen  = 1;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   352
2718
137cdf41bcec Cosmetic change : rtdm_in_rt_context instead of ipipe_root_p.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2717
diff changeset
   353
	if (rtdm_in_rt_context())
2717
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   354
        ret = nrt_rtdm_sendmsg(dev->socket, &msg);
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   355
	else
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   356
        ret = rtdm_sendmsg(dev->socket, &msg, 0);
2709
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   357
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   358
    return ret == len ? NETDEV_TX_OK : NETDEV_TX_BUSY;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   359
}
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   360
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   361
/*****************************************************************************/
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   362
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   363
/** Polls the device.
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   364
 */
2717
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   365
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   366
// delegate to some rtdm thread when called from nrt context
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   367
struct recvmsg_params {
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   368
    int socket;
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   369
    struct user_msghdr *msg;
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   370
};
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   371
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   372
static int recvmsg_handler(struct rt_proc_call *call)
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   373
{
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   374
    struct recvmsg_params *params;
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   375
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   376
    params = rtpc_get_priv(call, struct recvmsg_params);
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   377
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   378
    return  rtdm_recvmsg(params->socket, params->msg, MSG_DONTWAIT);
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   379
}
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   380
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   381
static ssize_t
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   382
nrt_rtdm_recvmsg(int socket, struct user_msghdr *msg)
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   383
{
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   384
    int ret;
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   385
    struct recvmsg_params params = {socket,msg};
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   386
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   387
    ret = rtpc_dispatch_call(recvmsg_handler, 0, &params,
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   388
                             sizeof(params), NULL, NULL);
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   389
    return ret;
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   390
}
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   391
2709
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   392
void ec_gen_device_poll(
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   393
        ec_gen_device_t *dev
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   394
        )
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   395
{
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   396
    struct user_msghdr msg;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   397
    struct iovec iov;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   398
    int ret, budget = 128; // FIXME
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   399
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   400
    ecdev_set_link(dev->ecdev, rtnetif_carrier_ok(dev->used_netdev));
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   401
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   402
    do {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   403
        iov.iov_base = dev->rx_buf;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   404
        iov.iov_len = EC_GEN_RX_BUF_SIZE;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   405
        memset(&msg, 0, sizeof(msg));
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   406
        msg.msg_iov     = &iov;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   407
        msg.msg_iovlen  = 1;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   408
2718
137cdf41bcec Cosmetic change : rtdm_in_rt_context instead of ipipe_root_p.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2717
diff changeset
   409
        if (rtdm_in_rt_context())
2717
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   410
            ret = nrt_rtdm_recvmsg(dev->socket, &msg);
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   411
        else
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   412
            ret = rtdm_recvmsg(dev->socket, &msg, MSG_DONTWAIT);
b5e3de0467a5 Xenomai won't merge .nrt ops delegation to rtdm task through rtpc. Moved it to rtdmnet.c.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2711
diff changeset
   413
2709
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   414
        if (ret > 0) {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   415
            ecdev_receive(dev->ecdev, dev->rx_buf, ret);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   416
        } else if (ret < 0) {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   417
            break;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   418
        }
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   419
        budget--;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   420
    } while (budget);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   421
}
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   422
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   423
/*****************************************************************************/
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   424
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   425
/** Offer device.
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   426
 */
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   427
int offer_device(
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   428
        ec_gen_interface_desc_t *desc
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   429
        )
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   430
{
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   431
    ec_gen_device_t *gendev;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   432
    int ret = 0;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   433
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   434
    gendev = kmalloc(sizeof(ec_gen_device_t), GFP_KERNEL);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   435
    if (!gendev) {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   436
        return -ENOMEM;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   437
    }
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   438
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   439
    ret = ec_gen_device_init(gendev);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   440
    if (ret) {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   441
        kfree(gendev);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   442
        return ret;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   443
    }
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   444
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   445
    if (ec_gen_device_offer(gendev, desc)) {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   446
        list_add_tail(&gendev->list, &generic_devices);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   447
    } else {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   448
        ec_gen_device_clear(gendev);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   449
        kfree(gendev);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   450
    }
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   451
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   452
    return ret;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   453
}
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   454
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   455
/*****************************************************************************/
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   456
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   457
/** Clear devices.
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   458
 */
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   459
void clear_devices(void)
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   460
{
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   461
    ec_gen_device_t *gendev, *next;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   462
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   463
    list_for_each_entry_safe(gendev, next, &generic_devices, list) {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   464
        list_del(&gendev->list);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   465
        ec_gen_device_clear(gendev);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   466
        kfree(gendev);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   467
    }
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   468
}
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   469
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   470
/*****************************************************************************/
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   471
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   472
/** Module initialization.
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   473
 *
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   474
 * Initializes \a master_count masters.
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   475
 * \return 0 on success, else < 0
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   476
 */
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   477
int __init ec_gen_init_module(void)
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   478
{
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   479
    int ret = 0;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   480
    int devices = 0;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   481
    int i;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   482
    struct list_head descs;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   483
    struct rtnet_device *rtdev;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   484
    ec_gen_interface_desc_t *desc, *next;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   485
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   486
    printk(KERN_INFO PFX "EtherCAT master RTnet Ethernet device module %s\n",
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   487
            EC_MASTER_VERSION);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   488
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   489
    INIT_LIST_HEAD(&generic_devices);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   490
    INIT_LIST_HEAD(&descs);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   491
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   492
    for (i = 0; i < MAX_RT_DEVICES; i++) {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   493
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   494
        rtdev = rtdev_get_by_index(i);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   495
        if (rtdev != NULL) {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   496
            mutex_lock(&rtdev->nrt_lock);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   497
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   498
            //if (test_bit(PRIV_FLAG_UP, &rtdev->priv_flags)) {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   499
            //    mutex_unlock(&rtdev->nrt_lock);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   500
            //    printk(KERN_ERR PFX "%s busy, skipping device!\n", rtdev->name);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   501
            //    rtdev_dereference(rtdev);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   502
            //    continue;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   503
            //}
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   504
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   505
            desc = kmalloc(sizeof(ec_gen_interface_desc_t), GFP_ATOMIC);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   506
            if (!desc) {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   507
                ret = -ENOMEM;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   508
                goto out_err;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   509
            }
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   510
            strncpy(desc->name, rtdev->name, IFNAMSIZ);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   511
            desc->netdev = rtdev;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   512
            desc->ifindex = rtdev->ifindex;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   513
            memcpy(desc->dev_addr, rtdev->dev_addr, ETH_ALEN);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   514
            list_add_tail(&desc->list, &descs);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   515
              mutex_unlock(&rtdev->nrt_lock);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   516
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   517
            devices++;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   518
        }
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   519
    }
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   520
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   521
    if (devices == 0) {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   522
        printk(KERN_ERR PFX "no real-time devices found!\n");
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   523
        ret = -ENODEV;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   524
        goto out_err;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   525
    }
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   526
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   527
    list_for_each_entry_safe(desc, next, &descs, list) {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   528
        ret = offer_device(desc);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   529
        if (ret) {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   530
            goto out_err;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   531
        }
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   532
        kfree(desc);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   533
    }
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   534
    return ret;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   535
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   536
out_err:
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   537
    list_for_each_entry_safe(desc, next, &descs, list) {
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   538
        list_del(&desc->list);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   539
        kfree(desc);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   540
    }
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   541
    clear_devices();
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   542
    return ret;
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   543
}
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   544
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   545
/*****************************************************************************/
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   546
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   547
/** Module cleanup.
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   548
 *
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   549
 * Clears all master instances.
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   550
 */
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   551
void __exit ec_gen_cleanup_module(void)
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   552
{
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   553
    clear_devices();
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   554
    printk(KERN_INFO PFX "Unloading.\n");
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   555
}
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   556
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   557
/*****************************************************************************/
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   558
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   559
/** \cond */
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   560
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   561
module_init(ec_gen_init_module);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   562
module_exit(ec_gen_cleanup_module);
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   563
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   564
/** \endcond */
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   565
e0c2f17ebed1 Added devices/rtdmnet.c, heavily based on devices/generic.c, and with similar purpose. It uses Xenomai's RTNet/RTDM socket instead of Linux socket.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   566
/*****************************************************************************/