1 /******************************************************************************/ 2 /* */ 3 /* bypass library, Copyright (c) 2004-2006 Silicom, Ltd */ 4 /* Corporation. */ 5 /* */ 6 /* This program is free software; you can redistribute it and/or modify */ 7 /* it under the terms of the GNU General Public License as published by */ 8 /* the Free Software Foundation, located in the file LICENSE. */ 9 /* */ 10 /* */ 11 /* */ 12 /******************************************************************************/ 13 14 #ifndef BP_IOCTL_H 15 #define BP_IOCTL_H 16 17 #define BP_CAP 0x01 //BIT_0 18 #define BP_STATUS_CAP 0x02 //BIT_1 19 #define BP_STATUS_CHANGE_CAP 0x04 //BIT_2 20 #define SW_CTL_CAP 0x08 //BIT_3 21 #define BP_DIS_CAP 0x10 //BIT_4 22 #define BP_DIS_STATUS_CAP 0x20 //BIT_5 23 #define STD_NIC_CAP 0x40 //BIT_6 24 #define BP_PWOFF_ON_CAP 0x80 //BIT_7 25 #define BP_PWOFF_OFF_CAP 0x0100 //BIT_8 26 #define BP_PWOFF_CTL_CAP 0x0200 //BIT_9 27 #define BP_PWUP_ON_CAP 0x0400 //BIT_10 28 #define BP_PWUP_OFF_CAP 0x0800 //BIT_11 29 #define BP_PWUP_CTL_CAP 0x1000 //BIT_12 30 #define WD_CTL_CAP 0x2000 //BIT_13 31 #define WD_STATUS_CAP 0x4000 //BIT_14 32 #define WD_TIMEOUT_CAP 0x8000 //BIT_15 33 #define TX_CTL_CAP 0x10000 //BIT_16 34 #define TX_STATUS_CAP 0x20000 //BIT_17 35 #define TAP_CAP 0x40000 //BIT_18 36 #define TAP_STATUS_CAP 0x80000 //BIT_19 37 #define TAP_STATUS_CHANGE_CAP 0x100000 //BIT_20 38 #define TAP_DIS_CAP 0x200000 //BIT_21 39 #define TAP_DIS_STATUS_CAP 0x400000 //BIT_22 40 #define TAP_PWUP_ON_CAP 0x800000 //BIT_23 41 #define TAP_PWUP_OFF_CAP 0x1000000 //BIT 24 42 #define TAP_PWUP_CTL_CAP 0x2000000 //BIT 25 43 #define NIC_CAP_NEG 0x4000000 //BIT 26 44 #define TPL_CAP 0x8000000 //BIT 27 45 #define DISC_CAP 0x10000000 //BIT 28 46 #define DISC_DIS_CAP 0x20000000 //BIT 29 47 #define DISC_PWUP_CTL_CAP 0x40000000 //BIT 30 48 49 #define WD_MIN_TIME_MASK(val) (val & 0xf) 50 #define WD_STEP_COUNT_MASK(val) ((val & 0xf) << 5) 51 #define WDT_STEP_TIME 0x10 //BIT_4 52 53 #define WD_MIN_TIME_GET(desc) (desc & 0xf) 54 #define WD_STEP_COUNT_GET(desc) (desc>>5) & 0xf 55 56 typedef enum { 57 IS_BYPASS = 1, 58 GET_BYPASS_SLAVE, 59 GET_BYPASS_CAPS, 60 GET_WD_SET_CAPS, 61 SET_BYPASS, 62 GET_BYPASS, 63 GET_BYPASS_CHANGE, 64 SET_BYPASS_WD, 65 GET_BYPASS_WD, 66 GET_WD_EXPIRE_TIME, 67 RESET_BYPASS_WD_TIMER, 68 SET_DIS_BYPASS, 69 GET_DIS_BYPASS, 70 SET_BYPASS_PWOFF, 71 GET_BYPASS_PWOFF, 72 SET_BYPASS_PWUP, 73 GET_BYPASS_PWUP, 74 SET_STD_NIC, 75 GET_STD_NIC, 76 SET_TX, 77 GET_TX, 78 SET_TAP, 79 GET_TAP, 80 GET_TAP_CHANGE, 81 SET_DIS_TAP, 82 GET_DIS_TAP, 83 SET_TAP_PWUP, 84 GET_TAP_PWUP, 85 SET_WD_EXP_MODE, 86 GET_WD_EXP_MODE, 87 SET_WD_AUTORESET, 88 GET_WD_AUTORESET, 89 SET_TPL, 90 GET_TPL, 91 SET_DISC, 92 GET_DISC, 93 GET_DISC_CHANGE, 94 SET_DIS_DISC, 95 GET_DIS_DISC, 96 SET_DISC_PWUP, 97 GET_DISC_PWUP, 98 99 GET_BYPASS_INFO = 100, 100 GET_BP_WAIT_AT_PWUP, 101 SET_BP_WAIT_AT_PWUP, 102 GET_BP_HW_RESET, 103 SET_BP_HW_RESET, 104 } CMND_TYPE; 105 106 typedef enum { 107 IF_SCAN_SD, 108 GET_DEV_NUM_SD, 109 IS_BYPASS_SD, 110 GET_BYPASS_SLAVE_SD, 111 GET_BYPASS_CAPS_SD, 112 GET_WD_SET_CAPS_SD, 113 SET_BYPASS_SD, 114 GET_BYPASS_SD, 115 GET_BYPASS_CHANGE_SD, 116 SET_BYPASS_WD_SD, 117 GET_BYPASS_WD_SD, 118 GET_WD_EXPIRE_TIME_SD, 119 RESET_BYPASS_WD_TIMER_SD, 120 SET_DIS_BYPASS_SD, 121 GET_DIS_BYPASS_SD, 122 SET_BYPASS_PWOFF_SD, 123 GET_BYPASS_PWOFF_SD, 124 SET_BYPASS_PWUP_SD, 125 GET_BYPASS_PWUP_SD, 126 SET_STD_NIC_SD, 127 GET_STD_NIC_SD, 128 SET_TX_SD, 129 GET_TX_SD, 130 SET_TAP_SD, 131 GET_TAP_SD, 132 GET_TAP_CHANGE_SD, 133 SET_DIS_TAP_SD, 134 GET_DIS_TAP_SD, 135 SET_TAP_PWUP_SD, 136 GET_TAP_PWUP_SD, 137 SET_WD_EXP_MODE_SD, 138 GET_WD_EXP_MODE_SD, 139 SET_WD_AUTORESET_SD, 140 GET_WD_AUTORESET_SD, 141 SET_TPL_SD, 142 GET_TPL_SD, 143 SET_DISC_SD, 144 GET_DISC_SD, 145 GET_DISC_CHANGE_SD, 146 SET_DIS_DISC_SD, 147 GET_DIS_DISC_SD, 148 SET_DISC_PWUP_SD, 149 GET_DISC_PWUP_SD, 150 151 GET_BYPASS_INFO_SD = 100, 152 GET_BP_WAIT_AT_PWUP_SD, 153 SET_BP_WAIT_AT_PWUP_SD, 154 GET_BP_HW_RESET_SD, 155 SET_BP_HW_RESET_SD, 156 157 } CMND_TYPE_SD; 158 159 #define SIOCGIFBYPASS SIOCDEVPRIVATE+10 160 161 struct bp_info { 162 char prod_name[14]; 163 unsigned char fw_ver; 164 }; 165 166 /* for passing single values */ 167 struct if_bypass { 168 char if_name[IFNAMSIZ]; 169 int cmd; 170 int data; 171 }; 172 struct if_bypass_info { 173 char if_name[IFNAMSIZ]; 174 char cmd; 175 struct bp_info bp_info; 176 }; 177 178 /* 179 * The major device number. We can't rely on dynamic 180 * registration any more, because ioctls need to know 181 * it. 182 */ 183 184 #define MAGIC_NUM 'J' 185 186 /* for passing single values */ 187 struct bpctl_cmd { 188 int status; 189 int data[8]; 190 int in_param[8]; 191 int out_param[8]; 192 }; 193 194 #define IOCTL_TX_MSG(cmd) _IOWR(MAGIC_NUM, cmd, struct bpctl_cmd) 195 196 #define DEVICE_NAME "bpctl" 197 198 #endif 199