1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright IBM Corp. 2007
10 #ifndef __QETH_CORE_H__
11 #define __QETH_CORE_H__
14 #include <linux/if_arp.h>
15 #include <linux/etherdevice.h>
16 #include <linux/if_vlan.h>
17 #include <linux/ctype.h>
18 #include <linux/in6.h>
19 #include <linux/bitops.h>
20 #include <linux/seq_file.h>
21 #include <linux/hashtable.h>
23 #include <linux/refcount.h>
24 #include <linux/workqueue.h>
27 #include <net/if_inet6.h>
28 #include <net/addrconf.h>
31 #include <asm/debug.h>
33 #include <asm/ccwdev.h>
34 #include <asm/ccwgroup.h>
35 #include <asm/sysinfo.h>
37 #include <uapi/linux/if_link.h>
39 #include "qeth_core_mpc.h"
42 * Debug Facility stuff
48 QETH_DBF_INFOS /* must be last element */
51 struct qeth_dbf_info {
52 char name[DEBUG_MAX_NAME_LEN];
57 struct debug_view *view;
61 #define QETH_DBF_CTRL_LEN 256
63 #define QETH_DBF_TEXT(name, level, text) \
64 debug_text_event(qeth_dbf[QETH_DBF_##name].id, level, text)
66 #define QETH_DBF_HEX(name, level, addr, len) \
67 debug_event(qeth_dbf[QETH_DBF_##name].id, level, (void *)(addr), len)
69 #define QETH_DBF_MESSAGE(level, text...) \
70 debug_sprintf_event(qeth_dbf[QETH_DBF_MSG].id, level, text)
72 #define QETH_DBF_TEXT_(name, level, text...) \
73 qeth_dbf_longtext(qeth_dbf[QETH_DBF_##name].id, level, text)
75 #define QETH_CARD_TEXT(card, level, text) \
76 debug_text_event(card->debug, level, text)
78 #define QETH_CARD_HEX(card, level, addr, len) \
79 debug_event(card->debug, level, (void *)(addr), len)
81 #define QETH_CARD_MESSAGE(card, text...) \
82 debug_sprintf_event(card->debug, level, text)
84 #define QETH_CARD_TEXT_(card, level, text...) \
85 qeth_dbf_longtext(card->debug, level, text)
87 #define SENSE_COMMAND_REJECT_BYTE 0
88 #define SENSE_COMMAND_REJECT_FLAG 0x80
89 #define SENSE_RESETTING_EVENT_BYTE 1
90 #define SENSE_RESETTING_EVENT_FLAG 0x80
92 static inline u32 qeth_get_device_id(struct ccw_device *cdev)
94 struct ccw_dev_id dev_id;
97 ccw_device_get_id(cdev, &dev_id);
99 id |= (u32) (dev_id.ssid << 16);
105 * Common IO related definitions
107 #define CARD_RDEV(card) card->read.ccwdev
108 #define CARD_WDEV(card) card->write.ccwdev
109 #define CARD_DDEV(card) card->data.ccwdev
110 #define CARD_BUS_ID(card) dev_name(&card->gdev->dev)
111 #define CARD_RDEV_ID(card) dev_name(&card->read.ccwdev->dev)
112 #define CARD_WDEV_ID(card) dev_name(&card->write.ccwdev->dev)
113 #define CARD_DDEV_ID(card) dev_name(&card->data.ccwdev->dev)
114 #define CCW_DEVID(cdev) (qeth_get_device_id(cdev))
115 #define CARD_DEVID(card) (CCW_DEVID(CARD_RDEV(card)))
118 struct qeth_routing_info {
119 enum qeth_routing_types type;
123 struct qeth_ipa_info {
124 __u32 supported_funcs;
128 /* SETBRIDGEPORT stuff */
129 enum qeth_sbp_roles {
130 QETH_SBP_ROLE_NONE = 0,
131 QETH_SBP_ROLE_PRIMARY = 1,
132 QETH_SBP_ROLE_SECONDARY = 2,
135 enum qeth_sbp_states {
136 QETH_SBP_STATE_INACTIVE = 0,
137 QETH_SBP_STATE_STANDBY = 1,
138 QETH_SBP_STATE_ACTIVE = 2,
141 #define QETH_SBP_HOST_NOTIFICATION 1
143 struct qeth_sbp_info {
144 __u32 supported_funcs;
145 enum qeth_sbp_roles role;
146 __u32 hostnotification:1;
147 __u32 reflect_promisc:1;
148 __u32 reflect_promisc_primary:1;
151 struct qeth_vnicc_info {
152 /* supported/currently configured VNICCs; updated in IPA exchanges */
155 /* supported commands: bitmasks which VNICCs support respective cmd */
157 u32 getset_timeout_sup;
158 /* timeout value for the learning characteristic */
159 u32 learning_timeout;
160 /* characteristics wanted/configured by user */
162 /* has user explicitly enabled rx_bcast while online? */
163 bool rx_bcast_enabled;
166 static inline int qeth_is_ipa_supported(struct qeth_ipa_info *ipa,
167 enum qeth_ipa_funcs func)
169 return (ipa->supported_funcs & func);
172 static inline int qeth_is_ipa_enabled(struct qeth_ipa_info *ipa,
173 enum qeth_ipa_funcs func)
175 return (ipa->supported_funcs & ipa->enabled_funcs & func);
178 #define qeth_adp_supported(c, f) \
179 qeth_is_ipa_supported(&c->options.adp, f)
180 #define qeth_adp_enabled(c, f) \
181 qeth_is_ipa_enabled(&c->options.adp, f)
182 #define qeth_is_supported(c, f) \
183 qeth_is_ipa_supported(&c->options.ipa4, f)
184 #define qeth_is_enabled(c, f) \
185 qeth_is_ipa_enabled(&c->options.ipa4, f)
186 #define qeth_is_supported6(c, f) \
187 qeth_is_ipa_supported(&c->options.ipa6, f)
188 #define qeth_is_enabled6(c, f) \
189 qeth_is_ipa_enabled(&c->options.ipa6, f)
190 #define qeth_is_ipafunc_supported(c, prot, f) \
191 ((prot == QETH_PROT_IPV6) ? \
192 qeth_is_supported6(c, f) : qeth_is_supported(c, f))
193 #define qeth_is_ipafunc_enabled(c, prot, f) \
194 ((prot == QETH_PROT_IPV6) ? \
195 qeth_is_enabled6(c, f) : qeth_is_enabled(c, f))
197 #define QETH_IDX_FUNC_LEVEL_OSD 0x0101
198 #define QETH_IDX_FUNC_LEVEL_IQD 0x4108
200 #define QETH_BUFSIZE 4096
201 #define CCW_CMD_WRITE 0x01
202 #define CCW_CMD_READ 0x02
207 #define QETH_TX_TIMEOUT 100 * HZ
208 #define QETH_RCD_TIMEOUT 60 * HZ
209 #define QETH_RECLAIM_WORK_TIME HZ
210 #define QETH_MAX_PORTNO 15
212 /*IPv6 address autoconfiguration stuff*/
213 #define UNIQUE_ID_IF_CREATE_ADDR_FAILED 0xfffe
214 #define UNIQUE_ID_NOT_BY_CARD 0x10000
216 /*****************************************************************************/
217 /* QDIO queue and buffer handling */
218 /*****************************************************************************/
219 #define QETH_MAX_QUEUES 4
220 #define QETH_IN_BUF_SIZE_DEFAULT 65536
221 #define QETH_IN_BUF_COUNT_DEFAULT 64
222 #define QETH_IN_BUF_COUNT_HSDEFAULT 128
223 #define QETH_IN_BUF_COUNT_MIN 8
224 #define QETH_IN_BUF_COUNT_MAX 128
225 #define QETH_MAX_BUFFER_ELEMENTS(card) ((card)->qdio.in_buf_size >> 12)
226 #define QETH_IN_BUF_REQUEUE_THRESHOLD(card) \
227 ((card)->qdio.in_buf_pool.buf_count / 2)
229 /* buffers we have to be behind before we get a PCI */
230 #define QETH_PCI_THRESHOLD_A(card) ((card)->qdio.in_buf_pool.buf_count+1)
231 /*enqueued free buffers left before we get a PCI*/
232 #define QETH_PCI_THRESHOLD_B(card) 0
233 /*not used unless the microcode gets patched*/
234 #define QETH_PCI_TIMER_VALUE(card) 3
236 /* priority queing */
237 #define QETH_PRIOQ_DEFAULT QETH_NO_PRIO_QUEUEING
238 #define QETH_DEFAULT_QUEUE 2
239 #define QETH_NO_PRIO_QUEUEING 0
240 #define QETH_PRIO_Q_ING_PREC 1
241 #define QETH_PRIO_Q_ING_TOS 2
242 #define QETH_PRIO_Q_ING_SKB 3
243 #define QETH_PRIO_Q_ING_VLAN 4
246 #define QETH_LOW_WATERMARK_PACK 2
247 #define QETH_HIGH_WATERMARK_PACK 5
248 #define QETH_WATERMARK_PACK_FUZZ 1
250 /* large receive scatter gather copy break */
251 #define QETH_RX_SG_CB (PAGE_SIZE >> 1)
252 #define QETH_RX_PULL_LEN 256
254 struct qeth_hdr_layer3 {
257 __u16 inbound_checksum; /*TSO:__u16 seqno */
258 __u32 token; /*TSO: __u32 reserved */
266 struct in6_addr ipv6_addr;
282 struct qeth_hdr_layer2 {
292 } __attribute__ ((packed));
294 struct qeth_hdr_osn {
303 } __attribute__ ((packed));
307 struct qeth_hdr_layer2 l2;
308 struct qeth_hdr_layer3 l3;
309 struct qeth_hdr_osn osn;
311 } __attribute__ ((packed));
313 /*TCP Segmentation Offload header*/
314 struct qeth_hdr_ext_tso {
325 } __attribute__ ((packed));
327 struct qeth_hdr_tso {
328 struct qeth_hdr hdr; /*hdr->hdr.l3.xxx*/
329 struct qeth_hdr_ext_tso ext;
330 } __attribute__ ((packed));
333 /* flags for qeth_hdr.flags */
334 #define QETH_HDR_PASSTHRU 0x10
335 #define QETH_HDR_IPV6 0x80
336 #define QETH_HDR_CAST_MASK 0x07
337 enum qeth_cast_flags {
338 QETH_CAST_UNICAST = 0x06,
339 QETH_CAST_MULTICAST = 0x04,
340 QETH_CAST_BROADCAST = 0x05,
341 QETH_CAST_ANYCAST = 0x07,
342 QETH_CAST_NOCAST = 0x00,
345 enum qeth_layer2_frame_flags {
346 QETH_LAYER2_FLAG_MULTICAST = 0x01,
347 QETH_LAYER2_FLAG_BROADCAST = 0x02,
348 QETH_LAYER2_FLAG_UNICAST = 0x04,
349 QETH_LAYER2_FLAG_VLAN = 0x10,
352 enum qeth_header_ids {
353 QETH_HEADER_TYPE_LAYER3 = 0x01,
354 QETH_HEADER_TYPE_LAYER2 = 0x02,
355 QETH_HEADER_TYPE_L3_TSO = 0x03,
356 QETH_HEADER_TYPE_OSN = 0x04,
357 QETH_HEADER_TYPE_L2_TSO = 0x06,
359 /* flags for qeth_hdr.ext_flags */
360 #define QETH_HDR_EXT_VLAN_FRAME 0x01
361 #define QETH_HDR_EXT_TOKEN_ID 0x02
362 #define QETH_HDR_EXT_INCLUDE_VLAN_TAG 0x04
363 #define QETH_HDR_EXT_SRC_MAC_ADDR 0x08
364 #define QETH_HDR_EXT_CSUM_HDR_REQ 0x10
365 #define QETH_HDR_EXT_CSUM_TRANSP_REQ 0x20
366 #define QETH_HDR_EXT_UDP 0x40 /*bit off for TCP*/
368 enum qeth_qdio_buffer_states {
370 * inbound: read out by driver; owned by hardware in order to be filled
371 * outbound: owned by driver in order to be filled
375 * inbound: filled by hardware; owned by driver in order to be read out
376 * outbound: filled by driver; owned by hardware in order to be sent
378 QETH_QDIO_BUF_PRIMED,
380 * inbound: not applicable
381 * outbound: identified to be pending in TPQ
383 QETH_QDIO_BUF_PENDING,
385 * inbound: not applicable
386 * outbound: found in completion queue
390 * inbound: not applicable
391 * outbound: handled via transfer pending / completion queue
393 QETH_QDIO_BUF_HANDLED_DELAYED,
396 enum qeth_qdio_info_states {
397 QETH_QDIO_UNINITIALIZED,
399 QETH_QDIO_ESTABLISHED,
403 struct qeth_buffer_pool_entry {
404 struct list_head list;
405 struct list_head init_list;
406 void *elements[QDIO_MAX_ELEMENTS_PER_BUFFER];
409 struct qeth_qdio_buffer_pool {
410 struct list_head entry_list;
414 struct qeth_qdio_buffer {
415 struct qdio_buffer *buffer;
416 /* the buffer pool entry currently associated to this buffer */
417 struct qeth_buffer_pool_entry *pool_entry;
418 struct sk_buff *rx_skb;
422 struct qdio_buffer *qdio_bufs[QDIO_MAX_BUFFERS_PER_Q];
423 struct qeth_qdio_buffer bufs[QDIO_MAX_BUFFERS_PER_Q];
424 int next_buf_to_init;
427 struct qeth_qdio_out_buffer {
428 struct qdio_buffer *buffer;
430 int next_element_to_fill;
431 struct sk_buff_head skb_list;
432 int is_header[QDIO_MAX_ELEMENTS_PER_BUFFER];
434 struct qeth_qdio_out_q *q;
435 struct qeth_qdio_out_buffer *next_pending;
440 enum qeth_out_q_states {
443 QETH_OUT_Q_LOCKED_FLUSH,
446 #define QETH_CARD_STAT_ADD(_c, _stat, _val) ((_c)->stats._stat += (_val))
447 #define QETH_CARD_STAT_INC(_c, _stat) QETH_CARD_STAT_ADD(_c, _stat, 1)
449 #define QETH_TXQ_STAT_ADD(_q, _stat, _val) ((_q)->stats._stat += (_val))
450 #define QETH_TXQ_STAT_INC(_q, _stat) QETH_TXQ_STAT_ADD(_q, _stat, 1)
452 struct qeth_card_stats {
457 u64 rx_sg_alloc_page;
459 /* rtnl_link_stats64 */
468 struct qeth_out_q_stats {
477 u64 skbs_linearized_fail;
479 u64 packing_mode_switch;
481 /* rtnl_link_stats64 */
488 struct qeth_qdio_out_q {
489 struct qdio_buffer *qdio_bufs[QDIO_MAX_BUFFERS_PER_Q];
490 struct qeth_qdio_out_buffer *bufs[QDIO_MAX_BUFFERS_PER_Q];
491 struct qdio_outbuf_state *bufstates; /* convenience pointer */
492 struct qeth_out_q_stats stats;
494 struct qeth_card *card;
498 * index of buffer to be filled by driver; state EMPTY or PACKING
500 int next_buf_to_fill;
502 * number of buffers that are currently filled (PRIMED)
503 * -> these buffers are hardware-owned
505 atomic_t used_buffers;
506 /* indicates whether PCI flag must be set (or if one is outstanding) */
507 atomic_t set_pci_flags_count;
510 struct qeth_qdio_info {
514 struct qeth_qdio_q *in_q;
515 struct qeth_qdio_q *c_q;
516 struct qeth_qdio_buffer_pool in_buf_pool;
517 struct qeth_qdio_buffer_pool init_pool;
522 struct qeth_qdio_out_q *out_qs[QETH_MAX_QUEUES];
523 struct qdio_outbuf_state *out_bufstates;
525 /* priority queueing */
526 int do_prio_queueing;
527 int default_out_queue;
531 * buffer stuff for read channel
533 #define QETH_CMD_BUFFER_NO 8
536 * channel state machine
538 enum qeth_channel_states {
550 enum qeth_card_states {
552 CARD_STATE_HARDSETUP,
553 CARD_STATE_SOFTSETUP,
559 enum qeth_prot_versions {
560 QETH_PROT_IPV4 = 0x0004,
561 QETH_PROT_IPV6 = 0x0006,
564 enum qeth_cmd_buffer_state {
570 QETH_CQ_DISABLED = 0,
572 QETH_CQ_NOTAVAILABLE = 2,
579 struct list_head entries;
584 struct qeth_cmd_buffer {
585 enum qeth_cmd_buffer_state state;
586 struct qeth_channel *channel;
587 struct qeth_reply *reply;
589 void (*callback)(struct qeth_card *card, struct qeth_channel *channel,
590 struct qeth_cmd_buffer *iob);
593 static inline struct qeth_ipa_cmd *__ipa_cmd(struct qeth_cmd_buffer *iob)
595 return (struct qeth_ipa_cmd *)(iob->data + IPA_PDU_HEADER_SIZE);
599 * definition of a qeth channel, used for read and write
601 struct qeth_channel {
602 enum qeth_channel_states state;
605 wait_queue_head_t wait_q;
606 struct ccw_device *ccwdev;
607 /*command buffer for control data*/
608 struct qeth_cmd_buffer iob[QETH_CMD_BUFFER_NO];
609 atomic_t irq_pending;
614 * OSA card related definitions
621 __u32 cm_connection_w;
622 __u32 cm_connection_r;
625 __u32 ulp_connection_w;
626 __u32 ulp_connection_r;
638 struct list_head list;
639 wait_queue_head_t wait_q;
640 int (*callback)(struct qeth_card *, struct qeth_reply *,
643 unsigned long offset;
650 struct qeth_card_blkt {
653 int inter_packet_jumbo;
656 #define QETH_BROADCAST_WITH_ECHO 0x01
657 #define QETH_BROADCAST_WITHOUT_ECHO 0x02
658 #define QETH_LAYER2_MAC_REGISTERED 0x02
659 struct qeth_card_info {
660 unsigned short unit_addr2;
662 unsigned short chpid;
664 char mcl_level[QETH_MCL_LENGTH + 1];
665 u8 open_when_online:1;
668 enum qeth_card_types type;
669 enum qeth_link_types link_type;
670 int broadcast_capable;
673 struct qeth_card_blkt blkt;
674 enum qeth_ipa_promisc_modes promisc_mode;
675 __u32 diagass_support;
679 enum qeth_discipline_id {
680 QETH_DISCIPLINE_UNDETERMINED = -1,
681 QETH_DISCIPLINE_LAYER3 = 0,
682 QETH_DISCIPLINE_LAYER2 = 1,
685 struct qeth_card_options {
686 struct qeth_routing_info route4;
687 struct qeth_ipa_info ipa4;
688 struct qeth_ipa_info adp; /*Adapter parameters*/
689 struct qeth_routing_info route6;
690 struct qeth_ipa_info ipa6;
691 struct qeth_sbp_info sbp; /* SETBRIDGEPORT options */
692 struct qeth_vnicc_info vnicc; /* VNICC options */
694 enum qeth_discipline_id layer;
696 enum qeth_ipa_isolation_modes isolation;
697 enum qeth_ipa_isolation_modes prev_isolation;
703 #define IS_LAYER2(card) ((card)->options.layer == QETH_DISCIPLINE_LAYER2)
704 #define IS_LAYER3(card) ((card)->options.layer == QETH_DISCIPLINE_LAYER3)
707 * thread bits for qeth_card thread masks
710 QETH_RECOVER_THREAD = 1,
713 struct qeth_osn_info {
714 int (*assist_cb)(struct net_device *dev, void *data);
715 int (*data_cb)(struct sk_buff *skb);
718 struct qeth_discipline {
719 const struct device_type *devtype;
720 int (*process_rx_buffer)(struct qeth_card *card, int budget, int *done);
721 int (*recover)(void *ptr);
722 int (*setup) (struct ccwgroup_device *);
723 void (*remove) (struct ccwgroup_device *);
724 int (*set_online) (struct ccwgroup_device *);
725 int (*set_offline) (struct ccwgroup_device *);
726 int (*freeze)(struct ccwgroup_device *);
727 int (*thaw) (struct ccwgroup_device *);
728 int (*restore)(struct ccwgroup_device *);
729 int (*do_ioctl)(struct net_device *dev, struct ifreq *rq, int cmd);
730 int (*control_event_handler)(struct qeth_card *card,
731 struct qeth_ipa_cmd *cmd);
734 enum qeth_addr_disposition {
735 QETH_DISP_ADDR_DELETE = 0,
736 QETH_DISP_ADDR_DO_NOTHING = 1,
737 QETH_DISP_ADDR_ADD = 2,
743 struct qdio_buffer_element *b_element;
748 struct carrier_info {
754 struct qeth_switch_info {
759 #define QETH_NAPI_WEIGHT NAPI_POLL_WEIGHT
762 enum qeth_card_states state;
764 struct ccwgroup_device *gdev;
765 struct qeth_channel read;
766 struct qeth_channel write;
767 struct qeth_channel data;
769 struct net_device *dev;
770 struct qeth_card_stats stats;
771 struct qeth_card_info info;
772 struct qeth_token token;
773 struct qeth_seqno seqno;
774 struct qeth_card_options options;
776 struct workqueue_struct *event_wq;
777 wait_queue_head_t wait_q;
779 unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
780 DECLARE_HASHTABLE(mac_htable, 4);
781 DECLARE_HASHTABLE(ip_htable, 4);
782 DECLARE_HASHTABLE(ip_mc_htable, 4);
783 struct work_struct kernel_thread_starter;
784 spinlock_t thread_mask_lock;
785 unsigned long thread_start_mask;
786 unsigned long thread_allowed_mask;
787 unsigned long thread_running_mask;
789 struct qeth_ipato ipato;
790 struct list_head cmd_waiter_list;
791 /* QDIO buffer handling */
792 struct qeth_qdio_info qdio;
793 int read_or_write_problem;
794 struct qeth_osn_info osn_info;
795 struct qeth_discipline *discipline;
796 atomic_t force_alloc_skb;
797 struct service_level qeth_service_level;
798 struct qdio_ssqd_desc ssqd;
800 struct mutex conf_mutex;
801 struct mutex discipline_mutex;
802 struct napi_struct napi;
804 struct delayed_work buffer_reclaim_work;
806 struct work_struct close_dev_work;
809 static inline bool qeth_card_hw_is_reachable(struct qeth_card *card)
811 return card->state == CARD_STATE_SOFTSETUP;
814 struct qeth_trap_id {
822 /*some helper functions*/
823 #define QETH_CARD_IFNAME(card) (((card)->dev)? (card)->dev->name : "")
825 static inline bool qeth_netdev_is_registered(struct net_device *dev)
827 return dev->netdev_ops != NULL;
830 static inline void qeth_scrub_qdio_buffer(struct qdio_buffer *buf,
831 unsigned int elements)
835 for (i = 0; i < elements; i++)
836 memset(&buf->element[i], 0, sizeof(struct qdio_buffer_element));
837 buf->element[14].sflags = 0;
838 buf->element[15].sflags = 0;
842 * qeth_get_elements_for_range() - find number of SBALEs to cover range.
843 * @start: Start of the address range.
844 * @end: Address after the end of the range.
846 * Returns the number of pages, and thus QDIO buffer elements, needed to cover
847 * the specified address range.
849 static inline int qeth_get_elements_for_range(addr_t start, addr_t end)
851 return PFN_UP(end) - PFN_DOWN(start);
854 static inline int qeth_get_ip_version(struct sk_buff *skb)
856 struct vlan_ethhdr *veth = vlan_eth_hdr(skb);
857 __be16 prot = veth->h_vlan_proto;
859 if (prot == htons(ETH_P_8021Q))
860 prot = veth->h_vlan_encapsulated_proto;
863 case htons(ETH_P_IPV6):
865 case htons(ETH_P_IP):
872 static inline void qeth_rx_csum(struct qeth_card *card, struct sk_buff *skb,
875 if ((card->dev->features & NETIF_F_RXCSUM) &&
876 (flags & QETH_HDR_EXT_CSUM_TRANSP_REQ)) {
877 skb->ip_summed = CHECKSUM_UNNECESSARY;
878 QETH_CARD_STAT_INC(card, rx_skb_csum);
880 skb->ip_summed = CHECKSUM_NONE;
884 static inline void qeth_tx_csum(struct sk_buff *skb, u8 *flags, int ipv)
886 *flags |= QETH_HDR_EXT_CSUM_TRANSP_REQ;
887 if ((ipv == 4 && ip_hdr(skb)->protocol == IPPROTO_UDP) ||
888 (ipv == 6 && ipv6_hdr(skb)->nexthdr == IPPROTO_UDP))
889 *flags |= QETH_HDR_EXT_UDP;
892 static inline void qeth_put_buffer_pool_entry(struct qeth_card *card,
893 struct qeth_buffer_pool_entry *entry)
895 list_add_tail(&entry->list, &card->qdio.in_buf_pool.entry_list);
898 static inline int qeth_is_diagass_supported(struct qeth_card *card,
899 enum qeth_diags_cmds cmd)
901 return card->info.diagass_support & (__u32)cmd;
904 int qeth_send_simple_setassparms_prot(struct qeth_card *card,
905 enum qeth_ipa_funcs ipa_func,
906 u16 cmd_code, long data,
907 enum qeth_prot_versions prot);
909 static inline int qeth_send_simple_setassparms(struct qeth_card *card,
910 enum qeth_ipa_funcs ipa_func,
911 u16 cmd_code, long data)
913 return qeth_send_simple_setassparms_prot(card, ipa_func, cmd_code,
914 data, QETH_PROT_IPV4);
917 static inline int qeth_send_simple_setassparms_v6(struct qeth_card *card,
918 enum qeth_ipa_funcs ipa_func,
919 u16 cmd_code, long data)
921 return qeth_send_simple_setassparms_prot(card, ipa_func, cmd_code,
922 data, QETH_PROT_IPV6);
925 int qeth_get_priority_queue(struct qeth_card *card, struct sk_buff *skb,
927 static inline struct qeth_qdio_out_q *qeth_get_tx_queue(struct qeth_card *card,
929 int ipv, int cast_type)
931 if (IS_IQD(card) && cast_type != RTN_UNICAST)
932 return card->qdio.out_qs[card->qdio.no_out_queues - 1];
933 if (!card->qdio.do_prio_queueing)
934 return card->qdio.out_qs[card->qdio.default_out_queue];
935 return card->qdio.out_qs[qeth_get_priority_queue(card, skb, ipv)];
938 extern struct qeth_discipline qeth_l2_discipline;
939 extern struct qeth_discipline qeth_l3_discipline;
940 extern const struct ethtool_ops qeth_ethtool_ops;
941 extern const struct ethtool_ops qeth_osn_ethtool_ops;
942 extern const struct attribute_group *qeth_generic_attr_groups[];
943 extern const struct attribute_group *qeth_osn_attr_groups[];
944 extern const struct attribute_group qeth_device_attr_group;
945 extern const struct attribute_group qeth_device_blkt_group;
946 extern const struct device_type qeth_generic_devtype;
948 const char *qeth_get_cardname_short(struct qeth_card *);
949 int qeth_realloc_buffer_pool(struct qeth_card *, int);
950 int qeth_core_load_discipline(struct qeth_card *, enum qeth_discipline_id);
951 void qeth_core_free_discipline(struct qeth_card *);
953 /* exports for qeth discipline device drivers */
954 extern struct kmem_cache *qeth_core_header_cache;
955 extern struct qeth_dbf_info qeth_dbf[QETH_DBF_INFOS];
957 struct net_device *qeth_clone_netdev(struct net_device *orig);
958 struct qeth_card *qeth_get_card_by_busid(char *bus_id);
959 void qeth_set_allowed_threads(struct qeth_card *, unsigned long , int);
960 int qeth_threads_running(struct qeth_card *, unsigned long);
961 int qeth_do_run_thread(struct qeth_card *, unsigned long);
962 void qeth_clear_thread_start_bit(struct qeth_card *, unsigned long);
963 void qeth_clear_thread_running_bit(struct qeth_card *, unsigned long);
964 int qeth_core_hardsetup_card(struct qeth_card *card, bool *carrier_ok);
965 void qeth_print_status_message(struct qeth_card *);
966 int qeth_init_qdio_queues(struct qeth_card *);
967 int qeth_send_ipa_cmd(struct qeth_card *, struct qeth_cmd_buffer *,
969 (struct qeth_card *, struct qeth_reply *, unsigned long),
971 struct qeth_cmd_buffer *qeth_get_ipacmd_buffer(struct qeth_card *,
972 enum qeth_ipa_cmds, enum qeth_prot_versions);
973 struct sk_buff *qeth_core_get_next_skb(struct qeth_card *,
974 struct qeth_qdio_buffer *, struct qdio_buffer_element **, int *,
976 void qeth_schedule_recovery(struct qeth_card *);
977 int qeth_poll(struct napi_struct *napi, int budget);
978 void qeth_clear_ipacmd_list(struct qeth_card *);
979 int qeth_qdio_clear_card(struct qeth_card *, int);
980 void qeth_clear_working_pool_list(struct qeth_card *);
981 void qeth_clear_cmd_buffers(struct qeth_channel *);
982 void qeth_clear_qdio_buffers(struct qeth_card *);
983 void qeth_setadp_promisc_mode(struct qeth_card *);
984 int qeth_setadpparms_change_macaddr(struct qeth_card *);
985 void qeth_tx_timeout(struct net_device *);
986 void qeth_prepare_control_data(struct qeth_card *, int,
987 struct qeth_cmd_buffer *);
988 void qeth_release_buffer(struct qeth_channel *, struct qeth_cmd_buffer *);
989 void qeth_prepare_ipa_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob,
991 struct qeth_cmd_buffer *qeth_wait_for_buffer(struct qeth_channel *);
992 int qeth_query_switch_attributes(struct qeth_card *card,
993 struct qeth_switch_info *sw_info);
994 int qeth_query_card_info(struct qeth_card *card,
995 struct carrier_info *carrier_info);
996 unsigned int qeth_count_elements(struct sk_buff *skb, unsigned int data_offset);
997 int qeth_do_send_packet(struct qeth_card *card, struct qeth_qdio_out_q *queue,
998 struct sk_buff *skb, struct qeth_hdr *hdr,
999 unsigned int offset, unsigned int hd_len,
1000 int elements_needed);
1001 int qeth_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
1002 void qeth_dbf_longtext(debug_info_t *id, int level, char *text, ...);
1003 int qeth_set_access_ctrl_online(struct qeth_card *card, int fallback);
1004 int qeth_configure_cq(struct qeth_card *, enum qeth_cq);
1005 int qeth_hw_trap(struct qeth_card *, enum qeth_diags_trap_action);
1006 void qeth_trace_features(struct qeth_card *);
1007 int qeth_setassparms_cb(struct qeth_card *, struct qeth_reply *, unsigned long);
1008 struct qeth_cmd_buffer *qeth_get_setassparms_cmd(struct qeth_card *,
1009 enum qeth_ipa_funcs,
1011 enum qeth_prot_versions);
1012 int qeth_set_features(struct net_device *, netdev_features_t);
1013 void qeth_enable_hw_features(struct net_device *dev);
1014 netdev_features_t qeth_fix_features(struct net_device *, netdev_features_t);
1015 netdev_features_t qeth_features_check(struct sk_buff *skb,
1016 struct net_device *dev,
1017 netdev_features_t features);
1018 void qeth_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats);
1019 int qeth_open(struct net_device *dev);
1020 int qeth_stop(struct net_device *dev);
1022 int qeth_vm_request_mac(struct qeth_card *card);
1023 int qeth_xmit(struct qeth_card *card, struct sk_buff *skb,
1024 struct qeth_qdio_out_q *queue, int ipv, int cast_type,
1025 void (*fill_header)(struct qeth_qdio_out_q *queue,
1026 struct qeth_hdr *hdr, struct sk_buff *skb,
1027 int ipv, int cast_type,
1028 unsigned int data_len));
1030 /* exports for OSN */
1031 int qeth_osn_assist(struct net_device *, void *, int);
1032 int qeth_osn_register(unsigned char *read_dev_no, struct net_device **,
1033 int (*assist_cb)(struct net_device *, void *),
1034 int (*data_cb)(struct sk_buff *));
1035 void qeth_osn_deregister(struct net_device *);
1037 #endif /* __QETH_CORE_H__ */