0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef _LINUX_ARCDEVICE_H
0012 #define _LINUX_ARCDEVICE_H
0013
0014 #include <asm/timex.h>
0015 #include <linux/if_arcnet.h>
0016
0017 #ifdef __KERNEL__
0018 #include <linux/interrupt.h>
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 #define RECON_THRESHOLD 30
0031
0032
0033
0034
0035
0036
0037
0038
0039 #define TX_TIMEOUT (HZ * 200 / 1000)
0040
0041
0042 #undef ALPHA_WARNING
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052 #define D_NORMAL 1
0053 #define D_EXTRA 2
0054 #define D_INIT 4
0055 #define D_INIT_REASONS 8
0056 #define D_RECON 32
0057 #define D_PROTO 64
0058
0059 #define D_DURING 128
0060 #define D_TX 256
0061 #define D_RX 512
0062 #define D_SKB 1024
0063 #define D_SKB_SIZE 2048
0064 #define D_TIMING 4096
0065 #define D_DEBUG 8192
0066
0067 #ifndef ARCNET_DEBUG_MAX
0068 #define ARCNET_DEBUG_MAX (127)
0069 #endif
0070
0071 #ifndef ARCNET_DEBUG
0072 #define ARCNET_DEBUG (D_NORMAL | D_EXTRA)
0073 #endif
0074 extern int arcnet_debug;
0075
0076 #define BUGLVL(x) ((x) & ARCNET_DEBUG_MAX & arcnet_debug)
0077
0078
0079 #define arc_printk(x, dev, fmt, ...) \
0080 do { \
0081 if (BUGLVL(x)) { \
0082 if ((x) == D_NORMAL) \
0083 netdev_warn(dev, fmt, ##__VA_ARGS__); \
0084 else if ((x) < D_DURING) \
0085 netdev_info(dev, fmt, ##__VA_ARGS__); \
0086 else \
0087 netdev_dbg(dev, fmt, ##__VA_ARGS__); \
0088 } \
0089 } while (0)
0090
0091 #define arc_cont(x, fmt, ...) \
0092 do { \
0093 if (BUGLVL(x)) \
0094 pr_cont(fmt, ##__VA_ARGS__); \
0095 } while (0)
0096
0097
0098 #define TIME(dev, name, bytes, call) \
0099 do { \
0100 if (BUGLVL(D_TIMING)) { \
0101 unsigned long _x, _y; \
0102 _x = get_cycles(); \
0103 call; \
0104 _y = get_cycles(); \
0105 arc_printk(D_TIMING, dev, \
0106 "%s: %d bytes in %lu cycles == %lu Kbytes/100Mcycle\n", \
0107 name, bytes, _y - _x, \
0108 100000000 / 1024 * bytes / (_y - _x + 1)); \
0109 } else { \
0110 call; \
0111 } \
0112 } while (0)
0113
0114
0115
0116
0117
0118
0119 #define RESETtime (300)
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130 #define MTU 253
0131 #define MinTU 257
0132 #define XMTU 508
0133
0134
0135 #define TXFREEflag 0x01
0136 #define TXACKflag 0x02
0137 #define RECONflag 0x04
0138 #define TESTflag 0x08
0139 #define EXCNAKflag 0x08
0140 #define RESETflag 0x10
0141 #define RES1flag 0x20
0142 #define RES2flag 0x40
0143 #define NORXflag 0x80
0144
0145
0146 #define AUTOINCflag 0x40
0147 #define IOMAPflag 0x02
0148 #define ENABLE16flag 0x80
0149
0150
0151
0152
0153
0154
0155 #define NOTXcmd 0x01
0156 #define NORXcmd 0x02
0157 #define TXcmd 0x03
0158 #define RXcmd 0x04
0159 #define CONFIGcmd 0x05
0160 #define CFLAGScmd 0x06
0161 #define TESTcmd 0x07
0162 #define STARTIOcmd 0x18
0163
0164
0165 #define RESETclear 0x08
0166 #define CONFIGclear 0x10
0167
0168 #define EXCNAKclear 0x0E
0169
0170
0171 #define TESTload 0x08
0172
0173
0174 #define TESTvalue 0321
0175
0176
0177 #define RXbcasts 0x80
0178
0179
0180 #define NORMALconf 0x00
0181 #define EXTconf 0x08
0182
0183
0184
0185
0186 #define ARC_IS_5MBIT 1
0187 #define ARC_CAN_10MBIT 2
0188
0189
0190
0191 struct ArcProto {
0192 char suffix;
0193 int mtu;
0194 int is_ip;
0195
0196 void (*rx)(struct net_device *dev, int bufnum,
0197 struct archdr *pkthdr, int length);
0198 int (*build_header)(struct sk_buff *skb, struct net_device *dev,
0199 unsigned short ethproto, uint8_t daddr);
0200
0201
0202 int (*prepare_tx)(struct net_device *dev, struct archdr *pkt,
0203 int length, int bufnum);
0204 int (*continue_tx)(struct net_device *dev, int bufnum);
0205 int (*ack_tx)(struct net_device *dev, int acked);
0206 };
0207
0208 extern struct ArcProto *arc_proto_map[256], *arc_proto_default,
0209 *arc_bcast_proto, *arc_raw_proto;
0210
0211
0212
0213
0214
0215 struct Incoming {
0216 struct sk_buff *skb;
0217 __be16 sequence;
0218 uint8_t lastpacket,
0219 numpackets;
0220 };
0221
0222
0223 struct Outgoing {
0224 struct ArcProto *proto;
0225
0226
0227 struct sk_buff *skb;
0228 struct archdr *pkt;
0229 uint16_t length,
0230 dataleft,
0231 segnum,
0232 numsegs;
0233 };
0234
0235 #define ARCNET_LED_NAME_SZ (IFNAMSIZ + 6)
0236
0237 struct arcnet_local {
0238 uint8_t config,
0239 timeout,
0240 backplane,
0241 clockp,
0242 clockm,
0243 setup,
0244 setup2,
0245 intmask;
0246 uint8_t default_proto[256];
0247 int cur_tx,
0248 next_tx,
0249 cur_rx;
0250 int lastload_dest,
0251 lasttrans_dest;
0252 int timed_out;
0253 unsigned long last_timeout;
0254 char *card_name;
0255 int card_flags;
0256
0257
0258 spinlock_t lock;
0259
0260 struct led_trigger *tx_led_trig;
0261 char tx_led_trig_name[ARCNET_LED_NAME_SZ];
0262 struct led_trigger *recon_led_trig;
0263 char recon_led_trig_name[ARCNET_LED_NAME_SZ];
0264
0265 struct timer_list timer;
0266
0267 struct net_device *dev;
0268 int reply_status;
0269 struct tasklet_struct reply_tasklet;
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289 atomic_t buf_lock;
0290 int buf_queue[5];
0291 int next_buf, first_free_buf;
0292
0293
0294 unsigned long first_recon;
0295 unsigned long last_recon;
0296 int num_recons;
0297 int network_down;
0298
0299 int excnak_pending;
0300
0301
0302 int reset_in_progress;
0303 struct work_struct reset_work;
0304
0305 struct {
0306 uint16_t sequence;
0307 __be16 aborted_seq;
0308
0309 struct Incoming incoming[256];
0310 } rfc1201;
0311
0312
0313 struct Outgoing outgoing;
0314
0315
0316 struct {
0317 struct module *owner;
0318 void (*command)(struct net_device *dev, int cmd);
0319 int (*status)(struct net_device *dev);
0320 void (*intmask)(struct net_device *dev, int mask);
0321 int (*reset)(struct net_device *dev, int really_reset);
0322 void (*open)(struct net_device *dev);
0323 void (*close)(struct net_device *dev);
0324 void (*datatrigger) (struct net_device * dev, int enable);
0325 void (*recontrigger) (struct net_device * dev, int enable);
0326
0327 void (*copy_to_card)(struct net_device *dev, int bufnum,
0328 int offset, void *buf, int count);
0329 void (*copy_from_card)(struct net_device *dev, int bufnum,
0330 int offset, void *buf, int count);
0331 } hw;
0332
0333 void __iomem *mem_start;
0334 };
0335
0336 enum arcnet_led_event {
0337 ARCNET_LED_EVENT_RECON,
0338 ARCNET_LED_EVENT_OPEN,
0339 ARCNET_LED_EVENT_STOP,
0340 ARCNET_LED_EVENT_TX,
0341 };
0342
0343 void arcnet_led_event(struct net_device *netdev, enum arcnet_led_event event);
0344 void devm_arcnet_led_init(struct net_device *netdev, int index, int subid);
0345
0346 #if ARCNET_DEBUG_MAX & D_SKB
0347 void arcnet_dump_skb(struct net_device *dev, struct sk_buff *skb, char *desc);
0348 #else
0349 static inline
0350 void arcnet_dump_skb(struct net_device *dev, struct sk_buff *skb, char *desc)
0351 {
0352 }
0353 #endif
0354
0355 void arcnet_unregister_proto(struct ArcProto *proto);
0356 irqreturn_t arcnet_interrupt(int irq, void *dev_id);
0357
0358 struct net_device *alloc_arcdev(const char *name);
0359 void free_arcdev(struct net_device *dev);
0360
0361 int arcnet_open(struct net_device *dev);
0362 int arcnet_close(struct net_device *dev);
0363 netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
0364 struct net_device *dev);
0365 void arcnet_timeout(struct net_device *dev, unsigned int txqueue);
0366
0367 static inline void arcnet_set_addr(struct net_device *dev, u8 addr)
0368 {
0369 dev_addr_set(dev, &addr);
0370 }
0371
0372
0373
0374 #ifdef CONFIG_SA1100_CT6001
0375 #define BUS_ALIGN 2
0376 #else
0377 #define BUS_ALIGN 1
0378 #endif
0379
0380
0381
0382
0383 #define arcnet_inb(addr, offset) \
0384 inb((addr) + BUS_ALIGN * (offset))
0385 #define arcnet_outb(value, addr, offset) \
0386 outb(value, (addr) + BUS_ALIGN * (offset))
0387
0388 #define arcnet_insb(addr, offset, buffer, count) \
0389 insb((addr) + BUS_ALIGN * (offset), buffer, count)
0390 #define arcnet_outsb(addr, offset, buffer, count) \
0391 outsb((addr) + BUS_ALIGN * (offset), buffer, count)
0392
0393 #define arcnet_readb(addr, offset) \
0394 readb((addr) + (offset))
0395 #define arcnet_writeb(value, addr, offset) \
0396 writeb(value, (addr) + (offset))
0397
0398 #endif
0399 #endif