1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright IBM Corp. 2007
10 #ifndef __QETH_CORE_H__
11 #define __QETH_CORE_H__
13 #include <linux/completion.h>
15 #include <linux/if_arp.h>
16 #include <linux/etherdevice.h>
17 #include <linux/if_vlan.h>
18 #include <linux/ctype.h>
19 #include <linux/in6.h>
20 #include <linux/bitops.h>
21 #include <linux/seq_file.h>
22 #include <linux/hashtable.h>
24 #include <linux/refcount.h>
25 #include <linux/wait.h>
26 #include <linux/workqueue.h>
29 #include <net/if_inet6.h>
30 #include <net/addrconf.h>
33 #include <asm/debug.h>
35 #include <asm/ccwdev.h>
36 #include <asm/ccwgroup.h>
37 #include <asm/sysinfo.h>
39 #include <uapi/linux/if_link.h>
41 #include "qeth_core_mpc.h"
44 * Debug Facility stuff
50 QETH_DBF_INFOS /* must be last element */
53 struct qeth_dbf_info {
54 char name[DEBUG_MAX_NAME_LEN];
59 struct debug_view *view;
63 #define QETH_DBF_CTRL_LEN 256
65 #define QETH_DBF_TEXT(name, level, text) \
66 debug_text_event(qeth_dbf[QETH_DBF_##name].id, level, text)
68 #define QETH_DBF_HEX(name, level, addr, len) \
69 debug_event(qeth_dbf[QETH_DBF_##name].id, level, (void *)(addr), len)
71 #define QETH_DBF_MESSAGE(level, text...) \
72 debug_sprintf_event(qeth_dbf[QETH_DBF_MSG].id, level, text)
74 #define QETH_DBF_TEXT_(name, level, text...) \
75 qeth_dbf_longtext(qeth_dbf[QETH_DBF_##name].id, level, text)
77 #define QETH_CARD_TEXT(card, level, text) \
78 debug_text_event(card->debug, level, text)
80 #define QETH_CARD_HEX(card, level, addr, len) \
81 debug_event(card->debug, level, (void *)(addr), len)
83 #define QETH_CARD_MESSAGE(card, text...) \
84 debug_sprintf_event(card->debug, level, text)
86 #define QETH_CARD_TEXT_(card, level, text...) \
87 qeth_dbf_longtext(card->debug, level, text)
89 #define SENSE_COMMAND_REJECT_BYTE 0
90 #define SENSE_COMMAND_REJECT_FLAG 0x80
91 #define SENSE_RESETTING_EVENT_BYTE 1
92 #define SENSE_RESETTING_EVENT_FLAG 0x80
94 static inline u32 qeth_get_device_id(struct ccw_device *cdev)
96 struct ccw_dev_id dev_id;
99 ccw_device_get_id(cdev, &dev_id);
101 id |= (u32) (dev_id.ssid << 16);
107 * Common IO related definitions
109 #define CARD_RDEV(card) card->read.ccwdev
110 #define CARD_WDEV(card) card->write.ccwdev
111 #define CARD_DDEV(card) card->data.ccwdev
112 #define CARD_BUS_ID(card) dev_name(&card->gdev->dev)
113 #define CARD_RDEV_ID(card) dev_name(&card->read.ccwdev->dev)
114 #define CARD_WDEV_ID(card) dev_name(&card->write.ccwdev->dev)
115 #define CARD_DDEV_ID(card) dev_name(&card->data.ccwdev->dev)
116 #define CCW_DEVID(cdev) (qeth_get_device_id(cdev))
117 #define CARD_DEVID(card) (CCW_DEVID(CARD_RDEV(card)))
120 struct qeth_routing_info {
121 enum qeth_routing_types type;
125 struct qeth_ipa_info {
126 __u32 supported_funcs;
130 /* SETBRIDGEPORT stuff */
131 enum qeth_sbp_roles {
132 QETH_SBP_ROLE_NONE = 0,
133 QETH_SBP_ROLE_PRIMARY = 1,
134 QETH_SBP_ROLE_SECONDARY = 2,
137 enum qeth_sbp_states {
138 QETH_SBP_STATE_INACTIVE = 0,
139 QETH_SBP_STATE_STANDBY = 1,
140 QETH_SBP_STATE_ACTIVE = 2,
143 #define QETH_SBP_HOST_NOTIFICATION 1
145 struct qeth_sbp_info {
146 __u32 supported_funcs;
147 enum qeth_sbp_roles role;
148 __u32 hostnotification:1;
149 __u32 reflect_promisc:1;
150 __u32 reflect_promisc_primary:1;
153 struct qeth_vnicc_info {
154 /* supported/currently configured VNICCs; updated in IPA exchanges */
157 /* supported commands: bitmasks which VNICCs support respective cmd */
159 u32 getset_timeout_sup;
160 /* timeout value for the learning characteristic */
161 u32 learning_timeout;
162 /* characteristics wanted/configured by user */
164 /* has user explicitly enabled rx_bcast while online? */
165 bool rx_bcast_enabled;
168 static inline int qeth_is_ipa_supported(struct qeth_ipa_info *ipa,
169 enum qeth_ipa_funcs func)
171 return (ipa->supported_funcs & func);
174 static inline int qeth_is_ipa_enabled(struct qeth_ipa_info *ipa,
175 enum qeth_ipa_funcs func)
177 return (ipa->supported_funcs & ipa->enabled_funcs & func);
180 #define qeth_adp_supported(c, f) \
181 qeth_is_ipa_supported(&c->options.adp, f)
182 #define qeth_adp_enabled(c, f) \
183 qeth_is_ipa_enabled(&c->options.adp, f)
184 #define qeth_is_supported(c, f) \
185 qeth_is_ipa_supported(&c->options.ipa4, f)
186 #define qeth_is_enabled(c, f) \
187 qeth_is_ipa_enabled(&c->options.ipa4, f)
188 #define qeth_is_supported6(c, f) \
189 qeth_is_ipa_supported(&c->options.ipa6, f)
190 #define qeth_is_enabled6(c, f) \
191 qeth_is_ipa_enabled(&c->options.ipa6, f)
192 #define qeth_is_ipafunc_supported(c, prot, f) \
193 ((prot == QETH_PROT_IPV6) ? \
194 qeth_is_supported6(c, f) : qeth_is_supported(c, f))
195 #define qeth_is_ipafunc_enabled(c, prot, f) \
196 ((prot == QETH_PROT_IPV6) ? \
197 qeth_is_enabled6(c, f) : qeth_is_enabled(c, f))
199 #define QETH_IDX_FUNC_LEVEL_OSD 0x0101
200 #define QETH_IDX_FUNC_LEVEL_IQD 0x4108
202 #define QETH_BUFSIZE 4096
203 #define CCW_CMD_WRITE 0x01
204 #define CCW_CMD_READ 0x02
209 #define QETH_TX_TIMEOUT 100 * HZ
210 #define QETH_RCD_TIMEOUT 60 * HZ
211 #define QETH_RECLAIM_WORK_TIME HZ
212 #define QETH_MAX_PORTNO 15
214 /*IPv6 address autoconfiguration stuff*/
215 #define UNIQUE_ID_IF_CREATE_ADDR_FAILED 0xfffe
216 #define UNIQUE_ID_NOT_BY_CARD 0x10000
218 /*****************************************************************************/
219 /* QDIO queue and buffer handling */
220 /*****************************************************************************/
221 #define QETH_MAX_QUEUES 4
222 #define QETH_IQD_MIN_TXQ 2 /* One for ucast, one for mcast. */
223 #define QETH_IQD_MCAST_TXQ 0
224 #define QETH_IQD_MIN_UCAST_TXQ 1
225 #define QETH_IN_BUF_SIZE_DEFAULT 65536
226 #define QETH_IN_BUF_COUNT_DEFAULT 64
227 #define QETH_IN_BUF_COUNT_HSDEFAULT 128
228 #define QETH_IN_BUF_COUNT_MIN 8
229 #define QETH_IN_BUF_COUNT_MAX 128
230 #define QETH_MAX_BUFFER_ELEMENTS(card) ((card)->qdio.in_buf_size >> 12)
231 #define QETH_IN_BUF_REQUEUE_THRESHOLD(card) \
232 ((card)->qdio.in_buf_pool.buf_count / 2)
234 /* buffers we have to be behind before we get a PCI */
235 #define QETH_PCI_THRESHOLD_A(card) ((card)->qdio.in_buf_pool.buf_count+1)
236 /*enqueued free buffers left before we get a PCI*/
237 #define QETH_PCI_THRESHOLD_B(card) 0
238 /*not used unless the microcode gets patched*/
239 #define QETH_PCI_TIMER_VALUE(card) 3
241 /* priority queing */
242 #define QETH_PRIOQ_DEFAULT QETH_NO_PRIO_QUEUEING
243 #define QETH_DEFAULT_QUEUE 2
244 #define QETH_NO_PRIO_QUEUEING 0
245 #define QETH_PRIO_Q_ING_PREC 1
246 #define QETH_PRIO_Q_ING_TOS 2
247 #define QETH_PRIO_Q_ING_SKB 3
248 #define QETH_PRIO_Q_ING_VLAN 4
251 #define QETH_LOW_WATERMARK_PACK 2
252 #define QETH_HIGH_WATERMARK_PACK 5
253 #define QETH_WATERMARK_PACK_FUZZ 1
255 /* large receive scatter gather copy break */
256 #define QETH_RX_SG_CB (PAGE_SIZE >> 1)
257 #define QETH_RX_PULL_LEN 256
259 struct qeth_hdr_layer3 {
262 __u16 inbound_checksum; /*TSO:__u16 seqno */
263 __u32 token; /*TSO: __u32 reserved */
271 struct in6_addr ipv6_addr;
287 struct qeth_hdr_layer2 {
297 } __attribute__ ((packed));
299 struct qeth_hdr_osn {
308 } __attribute__ ((packed));
312 struct qeth_hdr_layer2 l2;
313 struct qeth_hdr_layer3 l3;
314 struct qeth_hdr_osn osn;
316 } __attribute__ ((packed));
318 /*TCP Segmentation Offload header*/
319 struct qeth_hdr_ext_tso {
330 } __attribute__ ((packed));
332 struct qeth_hdr_tso {
333 struct qeth_hdr hdr; /*hdr->hdr.l3.xxx*/
334 struct qeth_hdr_ext_tso ext;
335 } __attribute__ ((packed));
338 /* flags for qeth_hdr.flags */
339 #define QETH_HDR_PASSTHRU 0x10
340 #define QETH_HDR_IPV6 0x80
341 #define QETH_HDR_CAST_MASK 0x07
342 enum qeth_cast_flags {
343 QETH_CAST_UNICAST = 0x06,
344 QETH_CAST_MULTICAST = 0x04,
345 QETH_CAST_BROADCAST = 0x05,
346 QETH_CAST_ANYCAST = 0x07,
347 QETH_CAST_NOCAST = 0x00,
350 enum qeth_layer2_frame_flags {
351 QETH_LAYER2_FLAG_MULTICAST = 0x01,
352 QETH_LAYER2_FLAG_BROADCAST = 0x02,
353 QETH_LAYER2_FLAG_UNICAST = 0x04,
354 QETH_LAYER2_FLAG_VLAN = 0x10,
357 enum qeth_header_ids {
358 QETH_HEADER_TYPE_LAYER3 = 0x01,
359 QETH_HEADER_TYPE_LAYER2 = 0x02,
360 QETH_HEADER_TYPE_L3_TSO = 0x03,
361 QETH_HEADER_TYPE_OSN = 0x04,
362 QETH_HEADER_TYPE_L2_TSO = 0x06,
364 /* flags for qeth_hdr.ext_flags */
365 #define QETH_HDR_EXT_VLAN_FRAME 0x01
366 #define QETH_HDR_EXT_TOKEN_ID 0x02
367 #define QETH_HDR_EXT_INCLUDE_VLAN_TAG 0x04
368 #define QETH_HDR_EXT_SRC_MAC_ADDR 0x08
369 #define QETH_HDR_EXT_CSUM_HDR_REQ 0x10
370 #define QETH_HDR_EXT_CSUM_TRANSP_REQ 0x20
371 #define QETH_HDR_EXT_UDP 0x40 /*bit off for TCP*/
373 enum qeth_qdio_buffer_states {
375 * inbound: read out by driver; owned by hardware in order to be filled
376 * outbound: owned by driver in order to be filled
380 * inbound: filled by hardware; owned by driver in order to be read out
381 * outbound: filled by driver; owned by hardware in order to be sent
383 QETH_QDIO_BUF_PRIMED,
385 * inbound: not applicable
386 * outbound: identified to be pending in TPQ
388 QETH_QDIO_BUF_PENDING,
390 * inbound: not applicable
391 * outbound: found in completion queue
395 * inbound: not applicable
396 * outbound: handled via transfer pending / completion queue
398 QETH_QDIO_BUF_HANDLED_DELAYED,
401 enum qeth_qdio_info_states {
402 QETH_QDIO_UNINITIALIZED,
404 QETH_QDIO_ESTABLISHED,
408 struct qeth_buffer_pool_entry {
409 struct list_head list;
410 struct list_head init_list;
411 void *elements[QDIO_MAX_ELEMENTS_PER_BUFFER];
414 struct qeth_qdio_buffer_pool {
415 struct list_head entry_list;
419 struct qeth_qdio_buffer {
420 struct qdio_buffer *buffer;
421 /* the buffer pool entry currently associated to this buffer */
422 struct qeth_buffer_pool_entry *pool_entry;
423 struct sk_buff *rx_skb;
427 struct qdio_buffer *qdio_bufs[QDIO_MAX_BUFFERS_PER_Q];
428 struct qeth_qdio_buffer bufs[QDIO_MAX_BUFFERS_PER_Q];
429 int next_buf_to_init;
432 struct qeth_qdio_out_buffer {
433 struct qdio_buffer *buffer;
435 int next_element_to_fill;
436 struct sk_buff_head skb_list;
437 int is_header[QDIO_MAX_ELEMENTS_PER_BUFFER];
439 struct qeth_qdio_out_q *q;
440 struct qeth_qdio_out_buffer *next_pending;
445 enum qeth_out_q_states {
448 QETH_OUT_Q_LOCKED_FLUSH,
451 #define QETH_CARD_STAT_ADD(_c, _stat, _val) ((_c)->stats._stat += (_val))
452 #define QETH_CARD_STAT_INC(_c, _stat) QETH_CARD_STAT_ADD(_c, _stat, 1)
454 #define QETH_TXQ_STAT_ADD(_q, _stat, _val) ((_q)->stats._stat += (_val))
455 #define QETH_TXQ_STAT_INC(_q, _stat) QETH_TXQ_STAT_ADD(_q, _stat, 1)
457 struct qeth_card_stats {
462 u64 rx_sg_alloc_page;
464 /* rtnl_link_stats64 */
472 struct qeth_out_q_stats {
481 u64 skbs_linearized_fail;
483 u64 packing_mode_switch;
486 /* rtnl_link_stats64 */
493 struct qeth_qdio_out_q {
494 struct qdio_buffer *qdio_bufs[QDIO_MAX_BUFFERS_PER_Q];
495 struct qeth_qdio_out_buffer *bufs[QDIO_MAX_BUFFERS_PER_Q];
496 struct qdio_outbuf_state *bufstates; /* convenience pointer */
497 struct qeth_out_q_stats stats;
499 struct qeth_card *card;
503 * index of buffer to be filled by driver; state EMPTY or PACKING
505 int next_buf_to_fill;
507 * number of buffers that are currently filled (PRIMED)
508 * -> these buffers are hardware-owned
510 atomic_t used_buffers;
511 /* indicates whether PCI flag must be set (or if one is outstanding) */
512 atomic_t set_pci_flags_count;
515 static inline bool qeth_out_queue_is_full(struct qeth_qdio_out_q *queue)
517 return atomic_read(&queue->used_buffers) >= QDIO_MAX_BUFFERS_PER_Q;
520 struct qeth_qdio_info {
524 struct qeth_qdio_q *in_q;
525 struct qeth_qdio_q *c_q;
526 struct qeth_qdio_buffer_pool in_buf_pool;
527 struct qeth_qdio_buffer_pool init_pool;
532 struct qeth_qdio_out_q *out_qs[QETH_MAX_QUEUES];
533 struct qdio_outbuf_state *out_bufstates;
535 /* priority queueing */
536 int do_prio_queueing;
537 int default_out_queue;
541 * buffer stuff for read channel
543 #define QETH_CMD_BUFFER_NO 8
546 * channel state machine
548 enum qeth_channel_states {
559 enum qeth_card_states {
561 CARD_STATE_HARDSETUP,
562 CARD_STATE_SOFTSETUP,
568 enum qeth_prot_versions {
569 QETH_PROT_IPV4 = 0x0004,
570 QETH_PROT_IPV6 = 0x0006,
573 enum qeth_cmd_buffer_state {
579 QETH_CQ_DISABLED = 0,
581 QETH_CQ_NOTAVAILABLE = 2,
588 struct list_head entries;
593 struct qeth_cmd_buffer {
594 enum qeth_cmd_buffer_state state;
595 struct qeth_channel *channel;
596 struct qeth_reply *reply;
599 void (*finalize)(struct qeth_card *card, struct qeth_cmd_buffer *iob,
600 unsigned int length);
601 void (*callback)(struct qeth_card *card, struct qeth_channel *channel,
602 struct qeth_cmd_buffer *iob);
605 static inline struct qeth_ipa_cmd *__ipa_cmd(struct qeth_cmd_buffer *iob)
607 return (struct qeth_ipa_cmd *)(iob->data + IPA_PDU_HEADER_SIZE);
611 * definition of a qeth channel, used for read and write
613 struct qeth_channel {
614 enum qeth_channel_states state;
617 wait_queue_head_t wait_q;
618 struct ccw_device *ccwdev;
619 /*command buffer for control data*/
620 struct qeth_cmd_buffer iob[QETH_CMD_BUFFER_NO];
621 atomic_t irq_pending;
625 static inline bool qeth_trylock_channel(struct qeth_channel *channel)
627 return atomic_cmpxchg(&channel->irq_pending, 0, 1) == 0;
631 * OSA card related definitions
638 __u32 cm_connection_w;
639 __u32 cm_connection_r;
642 __u32 ulp_connection_w;
643 __u32 ulp_connection_r;
655 struct list_head list;
656 struct completion received;
657 int (*callback)(struct qeth_card *, struct qeth_reply *,
660 unsigned long offset;
666 struct qeth_card_blkt {
669 int inter_packet_jumbo;
672 #define QETH_BROADCAST_WITH_ECHO 0x01
673 #define QETH_BROADCAST_WITHOUT_ECHO 0x02
674 #define QETH_LAYER2_MAC_REGISTERED 0x02
675 struct qeth_card_info {
676 unsigned short unit_addr2;
678 unsigned short chpid;
680 char mcl_level[QETH_MCL_LENGTH + 1];
681 u8 open_when_online:1;
684 enum qeth_card_types type;
685 enum qeth_link_types link_type;
686 int broadcast_capable;
689 struct qeth_card_blkt blkt;
690 enum qeth_ipa_promisc_modes promisc_mode;
691 __u32 diagass_support;
695 enum qeth_discipline_id {
696 QETH_DISCIPLINE_UNDETERMINED = -1,
697 QETH_DISCIPLINE_LAYER3 = 0,
698 QETH_DISCIPLINE_LAYER2 = 1,
701 struct qeth_card_options {
702 struct qeth_routing_info route4;
703 struct qeth_ipa_info ipa4;
704 struct qeth_ipa_info adp; /*Adapter parameters*/
705 struct qeth_routing_info route6;
706 struct qeth_ipa_info ipa6;
707 struct qeth_sbp_info sbp; /* SETBRIDGEPORT options */
708 struct qeth_vnicc_info vnicc; /* VNICC options */
710 enum qeth_discipline_id layer;
712 enum qeth_ipa_isolation_modes isolation;
713 enum qeth_ipa_isolation_modes prev_isolation;
719 #define IS_LAYER2(card) ((card)->options.layer == QETH_DISCIPLINE_LAYER2)
720 #define IS_LAYER3(card) ((card)->options.layer == QETH_DISCIPLINE_LAYER3)
723 * thread bits for qeth_card thread masks
726 QETH_RECOVER_THREAD = 1,
729 struct qeth_osn_info {
730 int (*assist_cb)(struct net_device *dev, void *data);
731 int (*data_cb)(struct sk_buff *skb);
734 struct qeth_discipline {
735 const struct device_type *devtype;
736 int (*process_rx_buffer)(struct qeth_card *card, int budget, int *done);
737 int (*recover)(void *ptr);
738 int (*setup) (struct ccwgroup_device *);
739 void (*remove) (struct ccwgroup_device *);
740 int (*set_online) (struct ccwgroup_device *);
741 int (*set_offline) (struct ccwgroup_device *);
742 int (*freeze)(struct ccwgroup_device *);
743 int (*thaw) (struct ccwgroup_device *);
744 int (*restore)(struct ccwgroup_device *);
745 int (*do_ioctl)(struct net_device *dev, struct ifreq *rq, int cmd);
746 int (*control_event_handler)(struct qeth_card *card,
747 struct qeth_ipa_cmd *cmd);
750 enum qeth_addr_disposition {
751 QETH_DISP_ADDR_DELETE = 0,
752 QETH_DISP_ADDR_DO_NOTHING = 1,
753 QETH_DISP_ADDR_ADD = 2,
759 struct qdio_buffer_element *b_element;
764 struct carrier_info {
770 struct qeth_switch_info {
775 #define QETH_NAPI_WEIGHT NAPI_POLL_WEIGHT
778 enum qeth_card_states state;
780 struct ccwgroup_device *gdev;
781 struct qeth_channel read;
782 struct qeth_channel write;
783 struct qeth_channel data;
785 struct net_device *dev;
786 struct qeth_card_stats stats;
787 struct qeth_card_info info;
788 struct qeth_token token;
789 struct qeth_seqno seqno;
790 struct qeth_card_options options;
792 struct workqueue_struct *event_wq;
793 struct workqueue_struct *cmd_wq;
794 wait_queue_head_t wait_q;
795 unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
796 DECLARE_HASHTABLE(mac_htable, 4);
797 DECLARE_HASHTABLE(ip_htable, 4);
798 struct mutex ip_lock;
799 DECLARE_HASHTABLE(ip_mc_htable, 4);
800 struct work_struct rx_mode_work;
801 struct work_struct kernel_thread_starter;
802 spinlock_t thread_mask_lock;
803 unsigned long thread_start_mask;
804 unsigned long thread_allowed_mask;
805 unsigned long thread_running_mask;
806 struct qeth_ipato ipato;
807 struct list_head cmd_waiter_list;
808 /* QDIO buffer handling */
809 struct qeth_qdio_info qdio;
810 int read_or_write_problem;
811 struct qeth_osn_info osn_info;
812 struct qeth_discipline *discipline;
813 atomic_t force_alloc_skb;
814 struct service_level qeth_service_level;
815 struct qdio_ssqd_desc ssqd;
817 struct mutex conf_mutex;
818 struct mutex discipline_mutex;
819 struct napi_struct napi;
821 struct delayed_work buffer_reclaim_work;
823 struct work_struct close_dev_work;
826 static inline bool qeth_card_hw_is_reachable(struct qeth_card *card)
828 return card->state == CARD_STATE_SOFTSETUP;
831 struct qeth_trap_id {
839 /*some helper functions*/
840 #define QETH_CARD_IFNAME(card) (((card)->dev)? (card)->dev->name : "")
842 static inline bool qeth_netdev_is_registered(struct net_device *dev)
844 return dev->netdev_ops != NULL;
847 static inline u16 qeth_iqd_translate_txq(struct net_device *dev, u16 txq)
849 if (txq == QETH_IQD_MCAST_TXQ)
850 return dev->num_tx_queues - 1;
851 if (txq == dev->num_tx_queues - 1)
852 return QETH_IQD_MCAST_TXQ;
856 static inline void qeth_scrub_qdio_buffer(struct qdio_buffer *buf,
857 unsigned int elements)
861 for (i = 0; i < elements; i++)
862 memset(&buf->element[i], 0, sizeof(struct qdio_buffer_element));
863 buf->element[14].sflags = 0;
864 buf->element[15].sflags = 0;
868 * qeth_get_elements_for_range() - find number of SBALEs to cover range.
869 * @start: Start of the address range.
870 * @end: Address after the end of the range.
872 * Returns the number of pages, and thus QDIO buffer elements, needed to cover
873 * the specified address range.
875 static inline int qeth_get_elements_for_range(addr_t start, addr_t end)
877 return PFN_UP(end) - PFN_DOWN(start);
880 static inline int qeth_get_ip_version(struct sk_buff *skb)
882 struct vlan_ethhdr *veth = vlan_eth_hdr(skb);
883 __be16 prot = veth->h_vlan_proto;
885 if (prot == htons(ETH_P_8021Q))
886 prot = veth->h_vlan_encapsulated_proto;
889 case htons(ETH_P_IPV6):
891 case htons(ETH_P_IP):
898 static inline void qeth_rx_csum(struct qeth_card *card, struct sk_buff *skb,
901 if ((card->dev->features & NETIF_F_RXCSUM) &&
902 (flags & QETH_HDR_EXT_CSUM_TRANSP_REQ)) {
903 skb->ip_summed = CHECKSUM_UNNECESSARY;
904 QETH_CARD_STAT_INC(card, rx_skb_csum);
906 skb->ip_summed = CHECKSUM_NONE;
910 static inline void qeth_tx_csum(struct sk_buff *skb, u8 *flags, int ipv)
912 *flags |= QETH_HDR_EXT_CSUM_TRANSP_REQ;
913 if ((ipv == 4 && ip_hdr(skb)->protocol == IPPROTO_UDP) ||
914 (ipv == 6 && ipv6_hdr(skb)->nexthdr == IPPROTO_UDP))
915 *flags |= QETH_HDR_EXT_UDP;
918 static inline void qeth_put_buffer_pool_entry(struct qeth_card *card,
919 struct qeth_buffer_pool_entry *entry)
921 list_add_tail(&entry->list, &card->qdio.in_buf_pool.entry_list);
924 static inline int qeth_is_diagass_supported(struct qeth_card *card,
925 enum qeth_diags_cmds cmd)
927 return card->info.diagass_support & (__u32)cmd;
930 int qeth_send_simple_setassparms_prot(struct qeth_card *card,
931 enum qeth_ipa_funcs ipa_func,
932 u16 cmd_code, long data,
933 enum qeth_prot_versions prot);
935 static inline int qeth_send_simple_setassparms(struct qeth_card *card,
936 enum qeth_ipa_funcs ipa_func,
937 u16 cmd_code, long data)
939 return qeth_send_simple_setassparms_prot(card, ipa_func, cmd_code,
940 data, QETH_PROT_IPV4);
943 static inline int qeth_send_simple_setassparms_v6(struct qeth_card *card,
944 enum qeth_ipa_funcs ipa_func,
945 u16 cmd_code, long data)
947 return qeth_send_simple_setassparms_prot(card, ipa_func, cmd_code,
948 data, QETH_PROT_IPV6);
951 int qeth_get_priority_queue(struct qeth_card *card, struct sk_buff *skb);
953 extern struct qeth_discipline qeth_l2_discipline;
954 extern struct qeth_discipline qeth_l3_discipline;
955 extern const struct ethtool_ops qeth_ethtool_ops;
956 extern const struct ethtool_ops qeth_osn_ethtool_ops;
957 extern const struct attribute_group *qeth_generic_attr_groups[];
958 extern const struct attribute_group *qeth_osn_attr_groups[];
959 extern const struct attribute_group qeth_device_attr_group;
960 extern const struct attribute_group qeth_device_blkt_group;
961 extern const struct device_type qeth_generic_devtype;
963 const char *qeth_get_cardname_short(struct qeth_card *);
964 int qeth_realloc_buffer_pool(struct qeth_card *, int);
965 int qeth_core_load_discipline(struct qeth_card *, enum qeth_discipline_id);
966 void qeth_core_free_discipline(struct qeth_card *);
968 /* exports for qeth discipline device drivers */
969 extern struct kmem_cache *qeth_core_header_cache;
970 extern struct qeth_dbf_info qeth_dbf[QETH_DBF_INFOS];
972 struct net_device *qeth_clone_netdev(struct net_device *orig);
973 struct qeth_card *qeth_get_card_by_busid(char *bus_id);
974 void qeth_set_allowed_threads(struct qeth_card *, unsigned long , int);
975 int qeth_threads_running(struct qeth_card *, unsigned long);
976 int qeth_do_run_thread(struct qeth_card *, unsigned long);
977 void qeth_clear_thread_start_bit(struct qeth_card *, unsigned long);
978 void qeth_clear_thread_running_bit(struct qeth_card *, unsigned long);
979 int qeth_core_hardsetup_card(struct qeth_card *card, bool *carrier_ok);
980 void qeth_print_status_message(struct qeth_card *);
981 int qeth_init_qdio_queues(struct qeth_card *);
982 int qeth_send_ipa_cmd(struct qeth_card *, struct qeth_cmd_buffer *,
984 (struct qeth_card *, struct qeth_reply *, unsigned long),
986 struct qeth_cmd_buffer *qeth_get_ipacmd_buffer(struct qeth_card *,
987 enum qeth_ipa_cmds, enum qeth_prot_versions);
988 struct sk_buff *qeth_core_get_next_skb(struct qeth_card *,
989 struct qeth_qdio_buffer *, struct qdio_buffer_element **, int *,
991 void qeth_schedule_recovery(struct qeth_card *);
992 int qeth_poll(struct napi_struct *napi, int budget);
993 void qeth_clear_ipacmd_list(struct qeth_card *);
994 int qeth_qdio_clear_card(struct qeth_card *, int);
995 void qeth_clear_working_pool_list(struct qeth_card *);
996 void qeth_clear_cmd_buffers(struct qeth_channel *);
997 void qeth_drain_output_queues(struct qeth_card *card);
998 void qeth_setadp_promisc_mode(struct qeth_card *);
999 int qeth_setadpparms_change_macaddr(struct qeth_card *);
1000 void qeth_tx_timeout(struct net_device *);
1001 void qeth_release_buffer(struct qeth_channel *, struct qeth_cmd_buffer *);
1002 void qeth_prepare_ipa_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob,
1004 struct qeth_cmd_buffer *qeth_wait_for_buffer(struct qeth_channel *);
1005 int qeth_query_switch_attributes(struct qeth_card *card,
1006 struct qeth_switch_info *sw_info);
1007 int qeth_query_card_info(struct qeth_card *card,
1008 struct carrier_info *carrier_info);
1009 unsigned int qeth_count_elements(struct sk_buff *skb, unsigned int data_offset);
1010 int qeth_do_send_packet(struct qeth_card *card, struct qeth_qdio_out_q *queue,
1011 struct sk_buff *skb, struct qeth_hdr *hdr,
1012 unsigned int offset, unsigned int hd_len,
1013 int elements_needed);
1014 int qeth_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
1015 void qeth_dbf_longtext(debug_info_t *id, int level, char *text, ...);
1016 int qeth_set_access_ctrl_online(struct qeth_card *card, int fallback);
1017 int qeth_configure_cq(struct qeth_card *, enum qeth_cq);
1018 int qeth_hw_trap(struct qeth_card *, enum qeth_diags_trap_action);
1019 void qeth_trace_features(struct qeth_card *);
1020 int qeth_setassparms_cb(struct qeth_card *, struct qeth_reply *, unsigned long);
1021 struct qeth_cmd_buffer *qeth_get_setassparms_cmd(struct qeth_card *,
1022 enum qeth_ipa_funcs,
1024 enum qeth_prot_versions);
1025 int qeth_set_features(struct net_device *, netdev_features_t);
1026 void qeth_enable_hw_features(struct net_device *dev);
1027 netdev_features_t qeth_fix_features(struct net_device *, netdev_features_t);
1028 netdev_features_t qeth_features_check(struct sk_buff *skb,
1029 struct net_device *dev,
1030 netdev_features_t features);
1031 void qeth_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats);
1032 u16 qeth_iqd_select_queue(struct net_device *dev, struct sk_buff *skb,
1033 u8 cast_type, struct net_device *sb_dev);
1034 int qeth_open(struct net_device *dev);
1035 int qeth_stop(struct net_device *dev);
1037 int qeth_vm_request_mac(struct qeth_card *card);
1038 int qeth_xmit(struct qeth_card *card, struct sk_buff *skb,
1039 struct qeth_qdio_out_q *queue, int ipv, int cast_type,
1040 void (*fill_header)(struct qeth_qdio_out_q *queue,
1041 struct qeth_hdr *hdr, struct sk_buff *skb,
1042 int ipv, int cast_type,
1043 unsigned int data_len));
1045 /* exports for OSN */
1046 int qeth_osn_assist(struct net_device *, void *, int);
1047 int qeth_osn_register(unsigned char *read_dev_no, struct net_device **,
1048 int (*assist_cb)(struct net_device *, void *),
1049 int (*data_cb)(struct sk_buff *));
1050 void qeth_osn_deregister(struct net_device *);
1052 #endif /* __QETH_CORE_H__ */