| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /******************************************************* | 
 | 2 | *  Define constants                                    * | 
 | 3 | *                                                      * | 
 | 4 | ********************************************************/ | 
| Heiko Carstens | e018ba1 | 2006-02-01 03:06:31 -0800 | [diff] [blame] | 5 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | /*-----------------------------------------------------* | 
 | 7 | *     CCW command codes for CLAW protocol              * | 
 | 8 | *------------------------------------------------------*/ | 
 | 9 |  | 
 | 10 | #define CCW_CLAW_CMD_WRITE           0x01      /* write - not including link */ | 
 | 11 | #define CCW_CLAW_CMD_READ            0x02      /* read */ | 
 | 12 | #define CCW_CLAW_CMD_NOP             0x03      /* NOP */ | 
 | 13 | #define CCW_CLAW_CMD_SENSE           0x04      /* Sense */ | 
 | 14 | #define CCW_CLAW_CMD_SIGNAL_SMOD     0x05      /* Signal Status Modifier */ | 
 | 15 | #define CCW_CLAW_CMD_TIC             0x08      /* TIC */ | 
 | 16 | #define CCW_CLAW_CMD_READHEADER      0x12      /* read header data */ | 
 | 17 | #define CCW_CLAW_CMD_READFF          0x22      /* read an FF */ | 
 | 18 | #define CCW_CLAW_CMD_SENSEID         0xe4      /* Sense ID */ | 
 | 19 |  | 
 | 20 |  | 
 | 21 | /*-----------------------------------------------------* | 
 | 22 | *    CLAW Unique constants                             * | 
 | 23 | *------------------------------------------------------*/ | 
 | 24 |  | 
 | 25 | #define MORE_to_COME_FLAG       0x04   /* OR with write CCW in case of m-t-c */ | 
 | 26 | #define CLAW_IDLE               0x00   /* flag to indicate CLAW is idle */ | 
 | 27 | #define CLAW_BUSY               0xff   /* flag to indicate CLAW is busy */ | 
 | 28 | #define CLAW_PENDING            0x00   /* flag to indicate i/o is pending */ | 
 | 29 | #define CLAW_COMPLETE           0xff   /* flag to indicate i/o completed */ | 
 | 30 |  | 
 | 31 | /*-----------------------------------------------------* | 
| Matt LaPlante | 0779bf2 | 2006-11-30 05:24:39 +0100 | [diff] [blame] | 32 | *     CLAW control command code                        * | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | *------------------------------------------------------*/ | 
 | 34 |  | 
 | 35 | #define SYSTEM_VALIDATE_REQUEST   0x01  /* System Validate request */ | 
 | 36 | #define SYSTEM_VALIDATE_RESPONSE  0x02  /* System Validate response */ | 
 | 37 | #define CONNECTION_REQUEST        0x21  /* Connection request */ | 
 | 38 | #define CONNECTION_RESPONSE       0x22  /* Connection response */ | 
 | 39 | #define CONNECTION_CONFIRM        0x23  /* Connection confirm */ | 
 | 40 | #define DISCONNECT                0x24  /* Disconnect */ | 
 | 41 | #define CLAW_ERROR                0x41  /* CLAW error message */ | 
 | 42 | #define CLAW_VERSION_ID           2     /* CLAW version ID */ | 
 | 43 |  | 
 | 44 | /*-----------------------------------------------------* | 
 | 45 | *  CLAW adater sense bytes                             * | 
 | 46 | *------------------------------------------------------*/ | 
 | 47 |  | 
 | 48 | #define CLAW_ADAPTER_SENSE_BYTE 0x41   /* Stop command issued to adapter */ | 
 | 49 |  | 
 | 50 | /*-----------------------------------------------------* | 
 | 51 | *      CLAW control command return codes               * | 
 | 52 | *------------------------------------------------------*/ | 
 | 53 |  | 
 | 54 | #define CLAW_RC_NAME_MISMATCH       166  /*  names do not match */ | 
 | 55 | #define CLAW_RC_WRONG_VERSION       167  /*  wrong CLAW version number */ | 
 | 56 | #define CLAW_RC_HOST_RCV_TOO_SMALL  180  /*  Host maximum receive is   */ | 
 | 57 | 					 /*  less than Linux on zSeries*/ | 
 | 58 |                                          /*  transmit size             */ | 
 | 59 |  | 
 | 60 | /*-----------------------------------------------------* | 
 | 61 | *      CLAW Constants application name                 * | 
 | 62 | *------------------------------------------------------*/ | 
 | 63 |  | 
 | 64 | #define HOST_APPL_NAME          "TCPIP   " | 
 | 65 | #define WS_APPL_NAME_IP_LINK    "TCPIP   " | 
 | 66 | #define WS_APPL_NAME_IP_NAME	"IP      " | 
 | 67 | #define WS_APPL_NAME_API_LINK   "API     " | 
 | 68 | #define WS_APPL_NAME_PACKED     "PACKED  " | 
 | 69 | #define WS_NAME_NOT_DEF         "NOT_DEF " | 
 | 70 | #define PACKING_ASK		1 | 
 | 71 | #define PACK_SEND		2 | 
 | 72 | #define DO_PACKED		3 | 
 | 73 |  | 
 | 74 | #define MAX_ENVELOPE_SIZE       65536 | 
 | 75 | #define CLAW_DEFAULT_MTU_SIZE   4096 | 
 | 76 | #define DEF_PACK_BUFSIZE	32768 | 
 | 77 | #define READ                    0 | 
 | 78 | #define WRITE                   1 | 
 | 79 |  | 
 | 80 | #define TB_TX                   0          /* sk buffer handling in process  */ | 
 | 81 | #define TB_STOP                 1          /* network device stop in process */ | 
 | 82 | #define TB_RETRY                2          /* retry in process               */ | 
 | 83 | #define TB_NOBUFFER             3          /* no buffer on free queue        */ | 
 | 84 | #define CLAW_MAX_LINK_ID        1 | 
 | 85 | #define CLAW_MAX_DEV            256        /*      max claw devices          */ | 
 | 86 | #define MAX_NAME_LEN            8          /* host name, adapter name length */ | 
 | 87 | #define CLAW_FRAME_SIZE         4096 | 
| Kay Sievers | 2a0217d | 2008-10-10 21:33:09 +0200 | [diff] [blame] | 88 | #define CLAW_ID_SIZE		20+3 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 |  | 
 | 90 | /* state machine codes used in claw_irq_handler */ | 
 | 91 |  | 
 | 92 | #define CLAW_STOP                0 | 
 | 93 | #define CLAW_START_HALT_IO       1 | 
 | 94 | #define CLAW_START_SENSEID       2 | 
 | 95 | #define CLAW_START_READ          3 | 
 | 96 | #define CLAW_START_WRITE         4 | 
 | 97 |  | 
 | 98 | /*-----------------------------------------------------* | 
 | 99 | *    Lock flag                                         * | 
 | 100 | *------------------------------------------------------*/ | 
 | 101 | #define LOCK_YES             0 | 
 | 102 | #define LOCK_NO              1 | 
 | 103 |  | 
 | 104 | /*-----------------------------------------------------* | 
 | 105 | *    DBF Debug macros                                  * | 
 | 106 | *------------------------------------------------------*/ | 
 | 107 | #define CLAW_DBF_TEXT(level, name, text) \ | 
 | 108 | 	do { \ | 
 | 109 | 		debug_text_event(claw_dbf_##name, level, text); \ | 
 | 110 | 	} while (0) | 
 | 111 |  | 
 | 112 | #define CLAW_DBF_HEX(level,name,addr,len) \ | 
 | 113 | do { \ | 
 | 114 | 	debug_event(claw_dbf_##name,level,(void*)(addr),len); \ | 
 | 115 | } while (0) | 
 | 116 |  | 
| Peter Tiedemann | f33780d | 2008-02-08 13:09:05 +0100 | [diff] [blame] | 117 | /* Allow to sort out low debug levels early to avoid wasted sprints */ | 
 | 118 | static inline int claw_dbf_passes(debug_info_t *dbf_grp, int level) | 
 | 119 | { | 
 | 120 | 	return (level <= dbf_grp->level); | 
 | 121 | } | 
 | 122 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | #define CLAW_DBF_TEXT_(level,name,text...) \ | 
| Peter Tiedemann | f33780d | 2008-02-08 13:09:05 +0100 | [diff] [blame] | 124 | 	do { \ | 
 | 125 | 		if (claw_dbf_passes(claw_dbf_##name, level)) { \ | 
 | 126 | 			sprintf(debug_buffer, text); \ | 
 | 127 | 			debug_text_event(claw_dbf_##name, level, \ | 
 | 128 | 						debug_buffer); \ | 
 | 129 | 		} \ | 
 | 130 | 	} while (0) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 |  | 
 | 132 | /******************************************************* | 
 | 133 | *  Define Control Blocks                               * | 
 | 134 | *                                                      * | 
 | 135 | ********************************************************/ | 
 | 136 |  | 
 | 137 | /*------------------------------------------------------*/ | 
 | 138 | /*     CLAW header                                      */ | 
 | 139 | /*------------------------------------------------------*/ | 
 | 140 |  | 
 | 141 | struct clawh { | 
 | 142 |         __u16  length;     /* length of data read by preceding read CCW */ | 
 | 143 |         __u8   opcode;     /* equivalent read CCW */ | 
 | 144 |         __u8   flag;       /* flag of FF to indicate read was completed */ | 
 | 145 | }; | 
 | 146 |  | 
 | 147 | /*------------------------------------------------------*/ | 
 | 148 | /*     CLAW Packing header   4 bytes                    */ | 
 | 149 | /*------------------------------------------------------*/ | 
 | 150 | struct clawph { | 
 | 151 |        __u16 len;  	/* Length of Packed Data Area   */ | 
 | 152 |        __u8  flag;  	/* Reserved not used            */ | 
 | 153 |        __u8  link_num;	/* Link ID                      */ | 
 | 154 | }; | 
 | 155 |  | 
 | 156 | /*------------------------------------------------------*/ | 
 | 157 | /*     CLAW Ending struct ccwbk                         */ | 
 | 158 | /*------------------------------------------------------*/ | 
 | 159 | struct endccw { | 
 | 160 | 	__u32     real;            /* real address of this block */ | 
 | 161 |        __u8      write1;          /* write 1 is active */ | 
 | 162 |         __u8      read1;           /* read 1 is active  */ | 
 | 163 |         __u16     reserved;        /* reserved for future use */ | 
 | 164 |         struct ccw1    write1_nop1; | 
 | 165 |         struct ccw1    write1_nop2; | 
 | 166 |         struct ccw1    write2_nop1; | 
 | 167 |         struct ccw1    write2_nop2; | 
 | 168 |         struct ccw1    read1_nop1; | 
 | 169 |         struct ccw1    read1_nop2; | 
 | 170 |         struct ccw1    read2_nop1; | 
 | 171 |         struct ccw1    read2_nop2; | 
 | 172 | }; | 
 | 173 |  | 
 | 174 | /*------------------------------------------------------*/ | 
 | 175 | /*     CLAW struct ccwbk                                       */ | 
 | 176 | /*------------------------------------------------------*/ | 
 | 177 | struct ccwbk { | 
 | 178 |         void   *next;        /* pointer to next ccw block */ | 
 | 179 |         __u32     real;         /* real address of this ccw */ | 
 | 180 |         void      *p_buffer;    /* virtual address of data */ | 
 | 181 |         struct clawh     header;       /* claw header */ | 
 | 182 |         struct ccw1    write;   /* write CCW    */ | 
 | 183 |         struct ccw1    w_read_FF; /* read FF */ | 
 | 184 |         struct ccw1    w_TIC_1;        /* TIC */ | 
 | 185 |         struct ccw1    read;         /* read CCW  */ | 
 | 186 |         struct ccw1    read_h;        /* read header */ | 
 | 187 |         struct ccw1    signal;       /* signal SMOD  */ | 
 | 188 |         struct ccw1    r_TIC_1;        /* TIC1 */ | 
 | 189 |         struct ccw1    r_read_FF;      /* read FF  */ | 
 | 190 |         struct ccw1    r_TIC_2;        /* TIC2 */ | 
 | 191 | }; | 
 | 192 |  | 
 | 193 | /*------------------------------------------------------*/ | 
 | 194 | /*     CLAW control block                               */ | 
 | 195 | /*------------------------------------------------------*/ | 
 | 196 | struct clawctl { | 
 | 197 |         __u8    command;      /* control command */ | 
 | 198 |         __u8    version;      /* CLAW protocol version */ | 
 | 199 |         __u8    linkid;       /* link ID   */ | 
 | 200 |         __u8    correlator;   /* correlator */ | 
 | 201 |         __u8    rc;           /* return code */ | 
 | 202 |         __u8    reserved1;    /* reserved */ | 
 | 203 |         __u8    reserved2;    /* reserved */ | 
 | 204 |         __u8    reserved3;    /* reserved */ | 
 | 205 |         __u8    data[24];     /* command specific fields */ | 
 | 206 | }; | 
 | 207 |  | 
 | 208 | /*------------------------------------------------------*/ | 
 | 209 | /*     Data for SYSTEMVALIDATE command                  */ | 
 | 210 | /*------------------------------------------------------*/ | 
 | 211 | struct sysval  { | 
 | 212 |         char    WS_name[8];        /* Workstation System name  */ | 
 | 213 |         char    host_name[8];      /* Host system name     */ | 
 | 214 |         __u16   read_frame_size;   /* read frame size */ | 
 | 215 |         __u16   write_frame_size;  /* write frame size */ | 
 | 216 |         __u8    reserved[4];       /* reserved */ | 
 | 217 | }; | 
 | 218 |  | 
 | 219 | /*------------------------------------------------------*/ | 
 | 220 | /*     Data for Connect command                         */ | 
 | 221 | /*------------------------------------------------------*/ | 
 | 222 | struct conncmd  { | 
 | 223 |         char     WS_name[8];       /* Workstation application name  */ | 
 | 224 |         char     host_name[8];     /* Host application name      */ | 
 | 225 |         __u16    reserved1[2];     /* read frame size */ | 
 | 226 |         __u8     reserved2[4];     /* reserved  */ | 
 | 227 | }; | 
 | 228 |  | 
 | 229 | /*------------------------------------------------------*/ | 
 | 230 | /*     Data for CLAW error                              */ | 
 | 231 | /*------------------------------------------------------*/ | 
 | 232 | struct clawwerror  { | 
 | 233 |         char      reserved1[8];   /* reserved */ | 
 | 234 |         char      reserved2[8];   /* reserved  */ | 
 | 235 |         char      reserved3[8];   /* reserved  */ | 
 | 236 | }; | 
 | 237 |  | 
 | 238 | /*------------------------------------------------------*/ | 
 | 239 | /*     Data buffer for CLAW                             */ | 
 | 240 | /*------------------------------------------------------*/ | 
 | 241 | struct clawbuf  { | 
 | 242 |        char      buffer[MAX_ENVELOPE_SIZE];   /* data buffer */ | 
 | 243 | }; | 
 | 244 |  | 
 | 245 | /*------------------------------------------------------*/ | 
 | 246 | /*     Channel control block for read and write channel */ | 
 | 247 | /*------------------------------------------------------*/ | 
 | 248 |  | 
 | 249 | struct chbk { | 
 | 250 |         unsigned int        devno; | 
 | 251 |         int                 irq; | 
 | 252 | 	char 		    id[CLAW_ID_SIZE]; | 
 | 253 |        __u32               IO_active; | 
 | 254 |         __u8                claw_state; | 
 | 255 |         struct irb          *irb; | 
 | 256 |        	struct ccw_device   *cdev;  /* pointer to the channel device */ | 
 | 257 | 	struct net_device   *ndev; | 
 | 258 |         wait_queue_head_t   wait; | 
 | 259 |         struct tasklet_struct    tasklet; | 
 | 260 |         struct timer_list   timer; | 
 | 261 |         unsigned long       flag_a;    /* atomic flags */ | 
 | 262 | #define CLAW_BH_ACTIVE      0 | 
 | 263 |         unsigned long       flag_b;    /* atomic flags */ | 
 | 264 | #define CLAW_WRITE_ACTIVE   0 | 
 | 265 |         __u8                last_dstat; | 
 | 266 |         __u8                flag; | 
 | 267 | 	struct sk_buff_head collect_queue; | 
 | 268 | 	spinlock_t collect_lock; | 
 | 269 | #define CLAW_WRITE      0x02      /* - Set if this is a write channel */ | 
 | 270 | #define CLAW_READ	0x01      /* - Set if this is a read channel  */ | 
 | 271 | #define CLAW_TIMER      0x80      /* - Set if timer made the wake_up  */ | 
 | 272 | }; | 
 | 273 |  | 
 | 274 | /*--------------------------------------------------------------* | 
 | 275 | *           CLAW  environment block                             * | 
 | 276 | *---------------------------------------------------------------*/ | 
 | 277 |  | 
 | 278 | struct claw_env { | 
 | 279 |         unsigned int            devno[2];       /* device number */ | 
 | 280 |         char                    host_name[9];   /* Host name */ | 
 | 281 |         char                    adapter_name [9]; /* adapter name */ | 
 | 282 |         char                    api_type[9];    /* TCPIP, API or PACKED */ | 
 | 283 |         void                    *p_priv;        /* privptr */ | 
 | 284 |         __u16                   read_buffers;   /* read buffer number */ | 
 | 285 |         __u16                   write_buffers;  /* write buffer number */ | 
 | 286 |         __u16                   read_size;      /* read buffer size */ | 
 | 287 |         __u16                   write_size;     /* write buffer size */ | 
 | 288 |         __u16                   dev_id;         /* device ident */ | 
 | 289 | 	__u8			packing;	/* are we packing? */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 |         __u8                    in_use;         /* device active flag */ | 
 | 291 |         struct net_device       *ndev;    	/* backward ptr to the net dev*/ | 
 | 292 | }; | 
 | 293 |  | 
 | 294 | /*--------------------------------------------------------------* | 
 | 295 | *           CLAW  main control block                            * | 
 | 296 | *---------------------------------------------------------------*/ | 
 | 297 |  | 
 | 298 | struct claw_privbk { | 
 | 299 |         void *p_buff_ccw; | 
 | 300 |         __u32      p_buff_ccw_num; | 
 | 301 |         void  *p_buff_read; | 
 | 302 |         __u32      p_buff_read_num; | 
 | 303 |         __u32      p_buff_pages_perread; | 
 | 304 |         void  *p_buff_write; | 
 | 305 |         __u32      p_buff_write_num; | 
 | 306 |         __u32      p_buff_pages_perwrite; | 
 | 307 |         long       active_link_ID;           /* Active logical link ID */ | 
 | 308 |         struct ccwbk *p_write_free_chain;     /* pointer to free ccw chain */ | 
 | 309 |         struct ccwbk *p_write_active_first;   /* ptr to the first write ccw */ | 
 | 310 |         struct ccwbk *p_write_active_last;    /* ptr to the last write ccw */ | 
 | 311 |         struct ccwbk *p_read_active_first;    /* ptr to the first read ccw */ | 
 | 312 |         struct ccwbk *p_read_active_last;     /* ptr to the last read ccw */ | 
 | 313 |         struct endccw *p_end_ccw;              /*ptr to ending ccw */ | 
 | 314 |         struct ccwbk *p_claw_signal_blk;      /* ptr to signal block */ | 
 | 315 |         __u32      write_free_count;       /* number of free bufs for write */ | 
 | 316 | 	struct     net_device_stats  stats; /* 	 device status    */ | 
 | 317 |         struct chbk channel[2];            /* Channel control blocks */ | 
 | 318 |         __u8       mtc_skipping; | 
 | 319 |         int        mtc_offset; | 
 | 320 |         int        mtc_logical_link; | 
 | 321 |         void       *p_mtc_envelope; | 
 | 322 | 	struct	   sk_buff	*pk_skb;	/* packing buffer    */ | 
 | 323 | 	int	   pk_cnt; | 
 | 324 |         struct clawctl ctl_bk; | 
 | 325 |         struct claw_env *p_env; | 
 | 326 |         __u8       system_validate_comp; | 
 | 327 |         __u8       release_pend; | 
 | 328 |         __u8      checksum_received_ip_pkts; | 
 | 329 | 	__u8      buffs_alloc; | 
 | 330 |         struct endccw  end_ccw; | 
 | 331 |         unsigned long  tbusy; | 
 | 332 |  | 
 | 333 | }; | 
 | 334 |  | 
 | 335 |  | 
 | 336 | /************************************************************/ | 
 | 337 | /* define global constants                                  */ | 
 | 338 | /************************************************************/ | 
 | 339 |  | 
 | 340 | #define CCWBK_SIZE sizeof(struct ccwbk) | 
 | 341 |  | 
 | 342 |  |