Deleted Added
full compact
e1000_manage.c (169589) e1000_manage.c (173788)
1/*******************************************************************************
2
3 Copyright (c) 2001-2007, Intel Corporation
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
8

--- 16 unchanged lines hidden (view full) ---

25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
31
32*******************************************************************************/
1/*******************************************************************************
2
3 Copyright (c) 2001-2007, Intel Corporation
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
8

--- 16 unchanged lines hidden (view full) ---

25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
31
32*******************************************************************************/
33/*$FreeBSD: head/sys/dev/em/e1000_manage.c 169589 2007-05-16 00:14:23Z jfv $*/
33/* $FreeBSD: head/sys/dev/em/e1000_manage.c 173788 2007-11-20 21:41:22Z jfv $ */
34
35
36#include "e1000_api.h"
37#include "e1000_manage.h"
38
39static u8 e1000_calculate_checksum(u8 *buffer, u32 length);
40
41/**
42 * e1000_calculate_checksum - Calculate checksum for buffer
43 * @buffer: pointer to EEPROM
44 * @length: size of EEPROM to calculate a checksum for
45 *
46 * Calculates the checksum for some buffer on a specified length. The
47 * checksum calculated is returned.
48 **/
34
35
36#include "e1000_api.h"
37#include "e1000_manage.h"
38
39static u8 e1000_calculate_checksum(u8 *buffer, u32 length);
40
41/**
42 * e1000_calculate_checksum - Calculate checksum for buffer
43 * @buffer: pointer to EEPROM
44 * @length: size of EEPROM to calculate a checksum for
45 *
46 * Calculates the checksum for some buffer on a specified length. The
47 * checksum calculated is returned.
48 **/
49static u8
50e1000_calculate_checksum(u8 *buffer, u32 length)
49static u8 e1000_calculate_checksum(u8 *buffer, u32 length)
51{
52 u32 i;
53 u8 sum = 0;
54
55 DEBUGFUNC("e1000_calculate_checksum");
56
57 if (!buffer)
58 return 0;

--- 9 unchanged lines hidden (view full) ---

68 * @hw: pointer to the HW structure
69 *
70 * Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
71 *
72 * This function checks whether the HOST IF is enabled for command operaton
73 * and also checks whether the previous command is completed. It busy waits
74 * in case of previous command is not completed.
75 **/
50{
51 u32 i;
52 u8 sum = 0;
53
54 DEBUGFUNC("e1000_calculate_checksum");
55
56 if (!buffer)
57 return 0;

--- 9 unchanged lines hidden (view full) ---

67 * @hw: pointer to the HW structure
68 *
69 * Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
70 *
71 * This function checks whether the HOST IF is enabled for command operaton
72 * and also checks whether the previous command is completed. It busy waits
73 * in case of previous command is not completed.
74 **/
76s32
77e1000_mng_enable_host_if_generic(struct e1000_hw * hw)
75s32 e1000_mng_enable_host_if_generic(struct e1000_hw * hw)
78{
79 u32 hicr;
80 s32 ret_val = E1000_SUCCESS;
81 u8 i;
82
83 DEBUGFUNC("e1000_mng_enable_host_if_generic");
84
85 /* Check that the host interface is enabled. */

--- 23 unchanged lines hidden (view full) ---

109
110/**
111 * e1000_check_mng_mode_generic - Generic check managament mode
112 * @hw: pointer to the HW structure
113 *
114 * Reads the firmware semaphore register and returns true (>0) if
115 * manageability is enabled, else false (0).
116 **/
76{
77 u32 hicr;
78 s32 ret_val = E1000_SUCCESS;
79 u8 i;
80
81 DEBUGFUNC("e1000_mng_enable_host_if_generic");
82
83 /* Check that the host interface is enabled. */

--- 23 unchanged lines hidden (view full) ---

107
108/**
109 * e1000_check_mng_mode_generic - Generic check managament mode
110 * @hw: pointer to the HW structure
111 *
112 * Reads the firmware semaphore register and returns true (>0) if
113 * manageability is enabled, else false (0).
114 **/
117boolean_t
118e1000_check_mng_mode_generic(struct e1000_hw *hw)
115bool e1000_check_mng_mode_generic(struct e1000_hw *hw)
119{
120 u32 fwsm;
121
122 DEBUGFUNC("e1000_check_mng_mode_generic");
123
124 fwsm = E1000_READ_REG(hw, E1000_FWSM);
125
126 return ((fwsm & E1000_FWSM_MODE_MASK) ==
127 (E1000_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
128}
129
130/**
131 * e1000_enable_tx_pkt_filtering_generic - Enable packet filtering on TX
132 * @hw: pointer to the HW structure
133 *
134 * Enables packet filtering on transmit packets if manageability is enabled
135 * and host interface is enabled.
136 **/
116{
117 u32 fwsm;
118
119 DEBUGFUNC("e1000_check_mng_mode_generic");
120
121 fwsm = E1000_READ_REG(hw, E1000_FWSM);
122
123 return ((fwsm & E1000_FWSM_MODE_MASK) ==
124 (E1000_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT));
125}
126
127/**
128 * e1000_enable_tx_pkt_filtering_generic - Enable packet filtering on TX
129 * @hw: pointer to the HW structure
130 *
131 * Enables packet filtering on transmit packets if manageability is enabled
132 * and host interface is enabled.
133 **/
137boolean_t
138e1000_enable_tx_pkt_filtering_generic(struct e1000_hw *hw)
134bool e1000_enable_tx_pkt_filtering_generic(struct e1000_hw *hw)
139{
140 struct e1000_host_mng_dhcp_cookie *hdr = &hw->mng_cookie;
141 u32 *buffer = (u32 *)&hw->mng_cookie;
142 u32 offset;
143 s32 ret_val, hdr_csum, csum;
144 u8 i, len;
135{
136 struct e1000_host_mng_dhcp_cookie *hdr = &hw->mng_cookie;
137 u32 *buffer = (u32 *)&hw->mng_cookie;
138 u32 offset;
139 s32 ret_val, hdr_csum, csum;
140 u8 i, len;
145 boolean_t tx_filter = TRUE;
141 bool tx_filter = TRUE;
146
147 DEBUGFUNC("e1000_enable_tx_pkt_filtering_generic");
148
149 /* No manageability, no filtering */
150 if (!e1000_check_mng_mode(hw)) {
151 tx_filter = FALSE;
152 goto out;
153 }
154
142
143 DEBUGFUNC("e1000_enable_tx_pkt_filtering_generic");
144
145 /* No manageability, no filtering */
146 if (!e1000_check_mng_mode(hw)) {
147 tx_filter = FALSE;
148 goto out;
149 }
150
155 /* If we can't read from the host interface for whatever
151 /*
152 * If we can't read from the host interface for whatever
156 * reason, disable filtering.
157 */
158 ret_val = e1000_mng_enable_host_if(hw);
159 if (ret_val != E1000_SUCCESS) {
160 tx_filter = FALSE;
161 goto out;
162 }
163

--- 4 unchanged lines hidden (view full) ---

168 *(buffer + i) = E1000_READ_REG_ARRAY_DWORD(hw,
169 E1000_HOST_IF,
170 offset + i);
171 }
172 hdr_csum = hdr->checksum;
173 hdr->checksum = 0;
174 csum = e1000_calculate_checksum((u8 *)hdr,
175 E1000_MNG_DHCP_COOKIE_LENGTH);
153 * reason, disable filtering.
154 */
155 ret_val = e1000_mng_enable_host_if(hw);
156 if (ret_val != E1000_SUCCESS) {
157 tx_filter = FALSE;
158 goto out;
159 }
160

--- 4 unchanged lines hidden (view full) ---

165 *(buffer + i) = E1000_READ_REG_ARRAY_DWORD(hw,
166 E1000_HOST_IF,
167 offset + i);
168 }
169 hdr_csum = hdr->checksum;
170 hdr->checksum = 0;
171 csum = e1000_calculate_checksum((u8 *)hdr,
172 E1000_MNG_DHCP_COOKIE_LENGTH);
176 /* If either the checksums or signature don't match, then
173 /*
174 * If either the checksums or signature don't match, then
177 * the cookie area isn't considered valid, in which case we
178 * take the safe route of assuming Tx filtering is enabled.
179 */
180 if (hdr_csum != csum)
181 goto out;
182 if (hdr->signature != E1000_IAMT_SIGNATURE)
183 goto out;
184

--- 9 unchanged lines hidden (view full) ---

194/**
195 * e1000_mng_write_dhcp_info_generic - Writes DHCP info to host interface
196 * @hw: pointer to the HW structure
197 * @buffer: pointer to the host interface
198 * @length: size of the buffer
199 *
200 * Writes the DHCP information to the host interface.
201 **/
175 * the cookie area isn't considered valid, in which case we
176 * take the safe route of assuming Tx filtering is enabled.
177 */
178 if (hdr_csum != csum)
179 goto out;
180 if (hdr->signature != E1000_IAMT_SIGNATURE)
181 goto out;
182

--- 9 unchanged lines hidden (view full) ---

192/**
193 * e1000_mng_write_dhcp_info_generic - Writes DHCP info to host interface
194 * @hw: pointer to the HW structure
195 * @buffer: pointer to the host interface
196 * @length: size of the buffer
197 *
198 * Writes the DHCP information to the host interface.
199 **/
202s32
203e1000_mng_write_dhcp_info_generic(struct e1000_hw * hw, u8 *buffer, u16 length)
200s32 e1000_mng_write_dhcp_info_generic(struct e1000_hw * hw, u8 *buffer,
201 u16 length)
204{
205 struct e1000_host_mng_command_header hdr;
206 s32 ret_val;
207 u32 hicr;
208
209 DEBUGFUNC("e1000_mng_write_dhcp_info_generic");
210
211 hdr.command_id = E1000_MNG_DHCP_TX_PAYLOAD_CMD;

--- 28 unchanged lines hidden (view full) ---

240
241/**
242 * e1000_mng_write_cmd_header_generic - Writes manageability command header
243 * @hw: pointer to the HW structure
244 * @hdr: pointer to the host interface command header
245 *
246 * Writes the command header after does the checksum calculation.
247 **/
202{
203 struct e1000_host_mng_command_header hdr;
204 s32 ret_val;
205 u32 hicr;
206
207 DEBUGFUNC("e1000_mng_write_dhcp_info_generic");
208
209 hdr.command_id = E1000_MNG_DHCP_TX_PAYLOAD_CMD;

--- 28 unchanged lines hidden (view full) ---

238
239/**
240 * e1000_mng_write_cmd_header_generic - Writes manageability command header
241 * @hw: pointer to the HW structure
242 * @hdr: pointer to the host interface command header
243 *
244 * Writes the command header after does the checksum calculation.
245 **/
248s32
249e1000_mng_write_cmd_header_generic(struct e1000_hw * hw,
250 struct e1000_host_mng_command_header * hdr)
246s32 e1000_mng_write_cmd_header_generic(struct e1000_hw * hw,
247 struct e1000_host_mng_command_header * hdr)
251{
252 u16 i, length = sizeof(struct e1000_host_mng_command_header);
253
254 DEBUGFUNC("e1000_mng_write_cmd_header_generic");
255
256 /* Write the whole command header structure with new checksum. */
257
258 hdr->checksum = e1000_calculate_checksum((u8 *)hdr, length);
259
260 length >>= 2;
261 /* Write the relevant command block into the ram area. */
262 for (i = 0; i < length; i++) {
248{
249 u16 i, length = sizeof(struct e1000_host_mng_command_header);
250
251 DEBUGFUNC("e1000_mng_write_cmd_header_generic");
252
253 /* Write the whole command header structure with new checksum. */
254
255 hdr->checksum = e1000_calculate_checksum((u8 *)hdr, length);
256
257 length >>= 2;
258 /* Write the relevant command block into the ram area. */
259 for (i = 0; i < length; i++) {
263 E1000_WRITE_REG_ARRAY_DWORD(hw, E1000_HOST_IF, i, *((u32 *) hdr + i));
260 E1000_WRITE_REG_ARRAY_DWORD(hw, E1000_HOST_IF, i,
261 *((u32 *) hdr + i));
264 E1000_WRITE_FLUSH(hw);
265 }
266
267 return E1000_SUCCESS;
268}
269
270/**
271 * e1000_mng_host_if_write_generic - Writes to the manageability host interface
272 * @hw: pointer to the HW structure
273 * @buffer: pointer to the host interface buffer
274 * @length: size of the buffer
275 * @offset: location in the buffer to write to
276 * @sum: sum of the data (not checksum)
277 *
278 * This function writes the buffer content at the offset given on the host if.
279 * It also does alignment considerations to do the writes in most efficient
280 * way. Also fills up the sum of the buffer in *buffer parameter.
281 **/
262 E1000_WRITE_FLUSH(hw);
263 }
264
265 return E1000_SUCCESS;
266}
267
268/**
269 * e1000_mng_host_if_write_generic - Writes to the manageability host interface
270 * @hw: pointer to the HW structure
271 * @buffer: pointer to the host interface buffer
272 * @length: size of the buffer
273 * @offset: location in the buffer to write to
274 * @sum: sum of the data (not checksum)
275 *
276 * This function writes the buffer content at the offset given on the host if.
277 * It also does alignment considerations to do the writes in most efficient
278 * way. Also fills up the sum of the buffer in *buffer parameter.
279 **/
282s32
283e1000_mng_host_if_write_generic(struct e1000_hw * hw, u8 *buffer, u16 length,
284 u16 offset, u8 *sum)
280s32 e1000_mng_host_if_write_generic(struct e1000_hw * hw, u8 *buffer,
281 u16 length, u16 offset, u8 *sum)
285{
286 u8 *tmp;
287 u8 *bufptr = buffer;
288 u32 data = 0;
289 s32 ret_val = E1000_SUCCESS;
290 u16 remaining, i, j, prev_bytes;
291
292 DEBUGFUNC("e1000_mng_host_if_write_generic");

--- 21 unchanged lines hidden (view full) ---

314 }
315
316 remaining = length & 0x3;
317 length -= remaining;
318
319 /* Calculate length in DWORDs */
320 length >>= 2;
321
282{
283 u8 *tmp;
284 u8 *bufptr = buffer;
285 u32 data = 0;
286 s32 ret_val = E1000_SUCCESS;
287 u16 remaining, i, j, prev_bytes;
288
289 DEBUGFUNC("e1000_mng_host_if_write_generic");

--- 21 unchanged lines hidden (view full) ---

311 }
312
313 remaining = length & 0x3;
314 length -= remaining;
315
316 /* Calculate length in DWORDs */
317 length >>= 2;
318
322 /* The device driver writes the relevant command block into the
323 * ram area. */
319 /*
320 * The device driver writes the relevant command block into the
321 * ram area.
322 */
324 for (i = 0; i < length; i++) {
325 for (j = 0; j < sizeof(u32); j++) {
326 *(tmp + j) = *bufptr++;
327 *sum += *(tmp + j);
328 }
329
330 E1000_WRITE_REG_ARRAY_DWORD(hw, E1000_HOST_IF, offset + i, data);
331 }

--- 14 unchanged lines hidden (view full) ---

346}
347
348/**
349 * e1000_enable_mng_pass_thru - Enable processing of ARP's
350 * @hw: pointer to the HW structure
351 *
352 * Verifies the hardware needs to allow ARPs to be processed by the host.
353 **/
323 for (i = 0; i < length; i++) {
324 for (j = 0; j < sizeof(u32); j++) {
325 *(tmp + j) = *bufptr++;
326 *sum += *(tmp + j);
327 }
328
329 E1000_WRITE_REG_ARRAY_DWORD(hw, E1000_HOST_IF, offset + i, data);
330 }

--- 14 unchanged lines hidden (view full) ---

345}
346
347/**
348 * e1000_enable_mng_pass_thru - Enable processing of ARP's
349 * @hw: pointer to the HW structure
350 *
351 * Verifies the hardware needs to allow ARPs to be processed by the host.
352 **/
354boolean_t
355e1000_enable_mng_pass_thru(struct e1000_hw *hw)
353bool e1000_enable_mng_pass_thru(struct e1000_hw *hw)
356{
357 u32 manc;
358 u32 fwsm, factps;
354{
355 u32 manc;
356 u32 fwsm, factps;
359 boolean_t ret_val = FALSE;
357 bool ret_val = FALSE;
360
361 DEBUGFUNC("e1000_enable_mng_pass_thru");
362
363 if (!hw->mac.asf_firmware_present)
364 goto out;
365
366 manc = E1000_READ_REG(hw, E1000_MANC);
367
368 if (!(manc & E1000_MANC_RCV_TCO_EN) ||
369 !(manc & E1000_MANC_EN_MAC_ADDR_FILTER))
370 goto out;
371
358
359 DEBUGFUNC("e1000_enable_mng_pass_thru");
360
361 if (!hw->mac.asf_firmware_present)
362 goto out;
363
364 manc = E1000_READ_REG(hw, E1000_MANC);
365
366 if (!(manc & E1000_MANC_RCV_TCO_EN) ||
367 !(manc & E1000_MANC_EN_MAC_ADDR_FILTER))
368 goto out;
369
372 if (hw->mac.arc_subsystem_valid == TRUE) {
370 if (hw->mac.arc_subsystem_valid) {
373 fwsm = E1000_READ_REG(hw, E1000_FWSM);
374 factps = E1000_READ_REG(hw, E1000_FACTPS);
375
376 if (!(factps & E1000_FACTPS_MNGCG) &&
377 ((fwsm & E1000_FWSM_MODE_MASK) ==
378 (e1000_mng_mode_pt << E1000_FWSM_MODE_SHIFT))) {
379 ret_val = TRUE;
380 goto out;
381 }
371 fwsm = E1000_READ_REG(hw, E1000_FWSM);
372 factps = E1000_READ_REG(hw, E1000_FACTPS);
373
374 if (!(factps & E1000_FACTPS_MNGCG) &&
375 ((fwsm & E1000_FWSM_MODE_MASK) ==
376 (e1000_mng_mode_pt << E1000_FWSM_MODE_SHIFT))) {
377 ret_val = TRUE;
378 goto out;
379 }
382 } else
380 } else {
383 if ((manc & E1000_MANC_SMBUS_EN) &&
384 !(manc & E1000_MANC_ASF_EN)) {
385 ret_val = TRUE;
386 goto out;
387 }
381 if ((manc & E1000_MANC_SMBUS_EN) &&
382 !(manc & E1000_MANC_ASF_EN)) {
383 ret_val = TRUE;
384 goto out;
385 }
386 }
388
389out:
390 return ret_val;
391}
392
387
388out:
389 return ret_val;
390}
391