^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright IBM Corp. 2001, 2007
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Authors: Fritz Elfert (felfert@millenux.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Peter Tiedemann (ptiedem@de.ibm.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #ifndef _CTCM_MAIN_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #define _CTCM_MAIN_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <asm/ccwdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <asm/ccwgroup.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/skbuff.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/netdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include "fsm.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include "ctcm_dbug.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include "ctcm_mpc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define CTC_DRIVER_NAME "ctcm"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define CTC_DEVICE_NAME "ctc"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define MPC_DEVICE_NAME "mpc"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define CTC_DEVICE_GENE CTC_DEVICE_NAME "%d"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define MPC_DEVICE_GENE MPC_DEVICE_NAME "%d"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define CHANNEL_FLAGS_READ 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define CHANNEL_FLAGS_WRITE 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define CHANNEL_FLAGS_INUSE 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define CHANNEL_FLAGS_BUFSIZE_CHANGED 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define CHANNEL_FLAGS_FAILED 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define CHANNEL_FLAGS_WAITIRQ 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define CHANNEL_FLAGS_RWMASK 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define CHANNEL_DIRECTION(f) (f & CHANNEL_FLAGS_RWMASK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define LOG_FLAG_ILLEGALPKT 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #define LOG_FLAG_ILLEGALSIZE 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #define LOG_FLAG_OVERRUN 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define LOG_FLAG_NOMEM 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #define ctcm_pr_debug(fmt, arg...) printk(KERN_DEBUG fmt, ##arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #define CTCM_PR_DEBUG(fmt, arg...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) if (do_debug) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) printk(KERN_DEBUG fmt, ##arg); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #define CTCM_PR_DBGDATA(fmt, arg...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) if (do_debug_data) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) printk(KERN_DEBUG fmt, ##arg); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #define CTCM_D3_DUMP(buf, len) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) if (do_debug_data) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) ctcmpc_dumpit(buf, len); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #define CTCM_CCW_DUMP(buf, len) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) if (do_debug_ccw) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) ctcmpc_dumpit(buf, len); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * Enum for classifying detected devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) enum ctcm_channel_types {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) /* Device is not a channel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) ctcm_channel_type_none,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) /* Device is a CTC/A */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) ctcm_channel_type_parallel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) /* Device is a FICON channel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) ctcm_channel_type_ficon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) /* Device is a ESCON channel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) ctcm_channel_type_escon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) * CCW commands, used in this driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) #define CCW_CMD_WRITE 0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) #define CCW_CMD_READ 0x02
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) #define CCW_CMD_NOOP 0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) #define CCW_CMD_TIC 0x08
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) #define CCW_CMD_SENSE_CMD 0x14
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) #define CCW_CMD_WRITE_CTL 0x17
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) #define CCW_CMD_SET_EXTENDED 0xc3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) #define CCW_CMD_PREPARE 0xe3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) #define CTCM_PROTO_S390 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) #define CTCM_PROTO_LINUX 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) #define CTCM_PROTO_LINUX_TTY 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) #define CTCM_PROTO_OS390 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) #define CTCM_PROTO_MPC 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #define CTCM_PROTO_MAX 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) #define CTCM_BUFSIZE_LIMIT 65535
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #define CTCM_BUFSIZE_DEFAULT 32768
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) #define MPC_BUFSIZE_DEFAULT CTCM_BUFSIZE_LIMIT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) #define CTCM_TIME_1_SEC 1000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) #define CTCM_TIME_5_SEC 5000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #define CTCM_TIME_10_SEC 10000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) #define CTCM_INITIAL_BLOCKLEN 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) #define CTCM_READ 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #define CTCM_WRITE 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #define CTCM_ID_SIZE 20+3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) struct ctcm_profile {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) unsigned long maxmulti;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) unsigned long maxcqueue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) unsigned long doios_single;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) unsigned long doios_multi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) unsigned long txlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) unsigned long tx_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) unsigned long send_stamp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) * Definition of one channel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) struct channel {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) struct channel *next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) char id[CTCM_ID_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) struct ccw_device *cdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) * Type of this channel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) * CTC/A or Escon for valid channels.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) enum ctcm_channel_types type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) * Misc. flags. See CHANNEL_FLAGS_... below
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) __u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) __u16 protocol; /* protocol of this channel (4 = MPC) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) * I/O and irq related stuff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) struct ccw1 *ccw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) struct irb *irb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) * RX/TX buffer size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) int max_bufsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) struct sk_buff *trans_skb; /* transmit/receive buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) struct sk_buff_head io_queue; /* universal I/O queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) struct tasklet_struct ch_tasklet; /* MPC ONLY */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) * TX queue for collecting skb's during busy.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) struct sk_buff_head collect_queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) * Amount of data in collect_queue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) int collect_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) * spinlock for collect_queue and collect_len
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) spinlock_t collect_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) * Timer for detecting unresposive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) * I/O operations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) fsm_timer timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) /* MPC ONLY section begin */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) __u32 th_seq_num; /* SNA TH seq number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) __u8 th_seg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) __u32 pdu_seq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) struct sk_buff *xid_skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) char *xid_skb_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) struct th_header *xid_th;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) struct xid2 *xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) char *xid_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) struct th_header *rcvd_xid_th;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) struct xid2 *rcvd_xid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) char *rcvd_xid_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) __u8 in_mpcgroup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) fsm_timer sweep_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) struct sk_buff_head sweep_queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) struct th_header *discontact_th;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) struct tasklet_struct ch_disc_tasklet;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) /* MPC ONLY section end */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) int retry; /* retry counter for misc. operations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) fsm_instance *fsm; /* finite state machine of this channel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) struct net_device *netdev; /* corresponding net_device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) struct ctcm_profile prof;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) __u8 *trans_skb_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) __u16 logflags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) __u8 sense_rc; /* last unit check sense code report control */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) struct ctcm_priv {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) struct net_device_stats stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) unsigned long tbusy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) /* The MPC group struct of this interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) struct mpc_group *mpcg; /* MPC only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) struct xid2 *xid; /* MPC only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) /* The finite state machine of this interface */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) fsm_instance *fsm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) /* The protocol of this device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) __u16 protocol;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) /* Timer for restarting after I/O Errors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) fsm_timer restart_timer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) int buffer_size; /* ctc only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) struct channel *channel[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) int ctcm_open(struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) int ctcm_close(struct net_device *dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) extern const struct attribute_group *ctcm_attr_groups[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) * Compatibility macros for busy handling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) * of network devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) static inline void ctcm_clear_busy_do(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) clear_bit(0, &(((struct ctcm_priv *)dev->ml_priv)->tbusy));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) netif_wake_queue(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) static inline void ctcm_clear_busy(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) struct mpc_group *grp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) grp = ((struct ctcm_priv *)dev->ml_priv)->mpcg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) if (!(grp && grp->in_sweep))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) ctcm_clear_busy_do(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) static inline int ctcm_test_and_set_busy(struct net_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) netif_stop_queue(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) return test_and_set_bit(0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) &(((struct ctcm_priv *)dev->ml_priv)->tbusy));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) extern int loglevel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) extern struct channel *channels;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) void ctcm_unpack_skb(struct channel *ch, struct sk_buff *pskb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) * Functions related to setup and device detection.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) static inline int ctcm_less_than(char *id1, char *id2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) unsigned long dev1, dev2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) id1 = id1 + 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) id2 = id2 + 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) dev1 = simple_strtoul(id1, &id1, 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) dev2 = simple_strtoul(id2, &id2, 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) return (dev1 < dev2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) int ctcm_ch_alloc_buffer(struct channel *ch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) static inline int ctcm_checkalloc_buffer(struct channel *ch)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) if (ch->trans_skb == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) return ctcm_ch_alloc_buffer(ch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) if (ch->flags & CHANNEL_FLAGS_BUFSIZE_CHANGED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) dev_kfree_skb(ch->trans_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) return ctcm_ch_alloc_buffer(ch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) struct mpc_group *ctcmpc_init_mpc_group(struct ctcm_priv *priv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) /* test if protocol attribute (of struct ctcm_priv or struct channel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) * has MPC protocol setting. Type is not checked
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) #define IS_MPC(p) ((p)->protocol == CTCM_PROTO_MPC)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) /* test if struct ctcm_priv of struct net_device has MPC protocol setting */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) #define IS_MPCDEV(dev) IS_MPC((struct ctcm_priv *)dev->ml_priv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) static inline gfp_t gfp_type(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) return in_interrupt() ? GFP_ATOMIC : GFP_KERNEL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) * Definition of our link level header.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) struct ll_header {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) __u16 length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) __u16 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) __u16 unused;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) #define LL_HEADER_LENGTH (sizeof(struct ll_header))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) #endif