diff options
Diffstat (limited to 'drivers/net/ethernet/intel/fm10k/fm10k_mbx.c')
-rw-r--r-- | drivers/net/ethernet/intel/fm10k/fm10k_mbx.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_mbx.c b/drivers/net/ethernet/intel/fm10k/fm10k_mbx.c index 14ee696e9830..1b2738380518 100644 --- a/drivers/net/ethernet/intel/fm10k/fm10k_mbx.c +++ b/drivers/net/ethernet/intel/fm10k/fm10k_mbx.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* Intel Ethernet Switch Host Interface Driver | 1 | /* Intel Ethernet Switch Host Interface Driver |
2 | * Copyright(c) 2013 - 2014 Intel Corporation. | 2 | * Copyright(c) 2013 - 2015 Intel Corporation. |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 4 | * This program is free software; you can redistribute it and/or modify it |
5 | * under the terms and conditions of the GNU General Public License, | 5 | * under the terms and conditions of the GNU General Public License, |
@@ -126,6 +126,18 @@ static u16 fm10k_fifo_head_drop(struct fm10k_mbx_fifo *fifo) | |||
126 | } | 126 | } |
127 | 127 | ||
128 | /** | 128 | /** |
129 | * fm10k_fifo_drop_all - Drop all messages in FIFO | ||
130 | * @fifo: pointer to FIFO | ||
131 | * | ||
132 | * This function resets the head pointer to drop all messages in the FIFO, | ||
133 | * and ensure the FIFO is empty. | ||
134 | **/ | ||
135 | static void fm10k_fifo_drop_all(struct fm10k_mbx_fifo *fifo) | ||
136 | { | ||
137 | fifo->head = fifo->tail; | ||
138 | } | ||
139 | |||
140 | /** | ||
129 | * fm10k_mbx_index_len - Convert a head/tail index into a length value | 141 | * fm10k_mbx_index_len - Convert a head/tail index into a length value |
130 | * @mbx: pointer to mailbox | 142 | * @mbx: pointer to mailbox |
131 | * @head: head index | 143 | * @head: head index |
@@ -315,7 +327,7 @@ static u16 fm10k_mbx_validate_msg_size(struct fm10k_mbx_info *mbx, u16 len) | |||
315 | } while (total_len < len); | 327 | } while (total_len < len); |
316 | 328 | ||
317 | /* message extends out of pushed section, but fits in FIFO */ | 329 | /* message extends out of pushed section, but fits in FIFO */ |
318 | if ((len < total_len) && (msg_len <= mbx->rx.size)) | 330 | if ((len < total_len) && (msg_len <= mbx->max_size)) |
319 | return 0; | 331 | return 0; |
320 | 332 | ||
321 | /* return length of invalid section */ | 333 | /* return length of invalid section */ |
@@ -326,8 +338,7 @@ static u16 fm10k_mbx_validate_msg_size(struct fm10k_mbx_info *mbx, u16 len) | |||
326 | * fm10k_mbx_write_copy - pulls data off of Tx FIFO and places it in mbmem | 338 | * fm10k_mbx_write_copy - pulls data off of Tx FIFO and places it in mbmem |
327 | * @mbx: pointer to mailbox | 339 | * @mbx: pointer to mailbox |
328 | * | 340 | * |
329 | * This function will take a section of the Rx FIFO and copy it into the | 341 | * This function will take a section of the Tx FIFO and copy it into the |
330 | mbx->tail--; | ||
331 | * mailbox memory. The offset in mbmem is based on the lower bits of the | 342 | * mailbox memory. The offset in mbmem is based on the lower bits of the |
332 | * tail and len determines the length to copy. | 343 | * tail and len determines the length to copy. |
333 | **/ | 344 | **/ |
@@ -818,7 +829,7 @@ static void fm10k_mbx_write(struct fm10k_hw *hw, struct fm10k_mbx_info *mbx) | |||
818 | /* write new msg header to notify recipient of change */ | 829 | /* write new msg header to notify recipient of change */ |
819 | fm10k_write_reg(hw, mbmem, mbx->mbx_hdr); | 830 | fm10k_write_reg(hw, mbmem, mbx->mbx_hdr); |
820 | 831 | ||
821 | /* write mailbox to sent interrupt */ | 832 | /* write mailbox to send interrupt */ |
822 | if (mbx->mbx_lock) | 833 | if (mbx->mbx_lock) |
823 | fm10k_write_reg(hw, mbx->mbx_reg, mbx->mbx_lock); | 834 | fm10k_write_reg(hw, mbx->mbx_reg, mbx->mbx_lock); |
824 | 835 | ||
@@ -1052,8 +1063,11 @@ static void fm10k_mbx_reset_work(struct fm10k_mbx_info *mbx) | |||
1052 | * @mbx: pointer to mailbox | 1063 | * @mbx: pointer to mailbox |
1053 | * @size: new value for max_size | 1064 | * @size: new value for max_size |
1054 | * | 1065 | * |
1055 | * This function will update the max_size value and drop any outgoing messages | 1066 | * This function updates the max_size value and drops any outgoing messages |
1056 | * from the head of the Tx FIFO that are larger than max_size. | 1067 | * at the head of the Tx FIFO if they are larger than max_size. It does not |
1068 | * drop all messages, as this is too difficult to parse and remove them from | ||
1069 | * the FIFO. Instead, rely on the checking to ensure that messages larger | ||
1070 | * than max_size aren't pushed into the memory buffer. | ||
1057 | **/ | 1071 | **/ |
1058 | static void fm10k_mbx_update_max_size(struct fm10k_mbx_info *mbx, u16 size) | 1072 | static void fm10k_mbx_update_max_size(struct fm10k_mbx_info *mbx, u16 size) |
1059 | { | 1073 | { |
@@ -1371,9 +1385,11 @@ static void fm10k_mbx_disconnect(struct fm10k_hw *hw, | |||
1371 | timeout -= FM10K_MBX_POLL_DELAY; | 1385 | timeout -= FM10K_MBX_POLL_DELAY; |
1372 | } while ((timeout > 0) && (mbx->state != FM10K_STATE_CLOSED)); | 1386 | } while ((timeout > 0) && (mbx->state != FM10K_STATE_CLOSED)); |
1373 | 1387 | ||
1374 | /* in case we didn't close just force the mailbox into shutdown */ | 1388 | /* in case we didn't close, just force the mailbox into shutdown and |
1389 | * drop all left over messages in the FIFO. | ||
1390 | */ | ||
1375 | fm10k_mbx_connect_reset(mbx); | 1391 | fm10k_mbx_connect_reset(mbx); |
1376 | fm10k_mbx_update_max_size(mbx, 0); | 1392 | fm10k_fifo_drop_all(&mbx->tx); |
1377 | 1393 | ||
1378 | fm10k_write_reg(hw, mbx->mbmem_reg, 0); | 1394 | fm10k_write_reg(hw, mbx->mbmem_reg, 0); |
1379 | } | 1395 | } |