Skip to content

Commit c1c27fb

Browse files
committed
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/net-next
Jeff Kirsher says: ==================== Intel Wired LAN Driver Updates 2014-06-26 This series contains updates to i40e and i40evf. Kamil provides a cleanup patch to i40e where we do not need to acquire the NVM for shadow RAM checksum calculation, since we only read the shadow RAM through SRCTL register. Paul provides a fix for handling HMC for big endian architectures for i40e and i40evf. Mitch provides four cleanup and fixes for i40evf. Fix an issue where if the VF driver fails to complete early init, then rmmod can cause a softlock when the driver tries to stop a watchdog timer that never got initialized. So add a check to see if the timer is actually initialized before stopping it. Make the function i40evf_send_api_ver() return more useful information, instead of just returning -EIO by propagating firmware errors back to the caller and log a message if the PF sends an invalid reply. Fix up a log message that was missing a word, which makes the log message more readable. Fix an initialization failure if many VFs are instantiated at the same time and the VF module is autoloaded by simply resending firmware request if there is no response the first time. Jacob does a rename of the function i40e_ptp_enable() to i40e_ptp_feature_enable(), like he did for ixgbe, to reduce possible confusion and ambugity in the purpose of the function. Does follow on PTP work on i40e, like he did for ixgbe, by breaking the PTP hardware control from the ioctl command for timestamping mode. By doing this, we can maintain state about the 1588 timestamping mode and properly re-enable to the last known mode during a re-initialization of 1588 bits. Anjali cleans up the i40e driver where TCP-IPv4 filters were being added twice, which seems to be left over from when we had to add two PTYPEs for one filter. Fixes the flow director sideband logic to detect when there is a full flow director table. Also fixes the programming of FDIR where a couple of fields in the descriptor setup that were not being programmed, which left the opportunity for stale data to be pushed as part of the descriptor next time it was used. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 0ff9275 + 99753ea commit c1c27fb

File tree

11 files changed

+373
-134
lines changed

11 files changed

+373
-134
lines changed

drivers/net/ethernet/intel/i40e/i40e.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ struct i40e_lump_tracking {
154154
#define I40E_DEFAULT_ATR_SAMPLE_RATE 20
155155
#define I40E_FDIR_MAX_RAW_PACKET_SIZE 512
156156
#define I40E_FDIR_BUFFER_FULL_MARGIN 10
157-
#define I40E_FDIR_BUFFER_HEAD_ROOM 200
157+
#define I40E_FDIR_BUFFER_HEAD_ROOM 32
158158

159159
enum i40e_fd_stat_idx {
160160
I40E_FD_STAT_ATR,
@@ -582,6 +582,7 @@ int i40e_add_del_fdir(struct i40e_vsi *vsi,
582582
struct i40e_fdir_filter *input, bool add);
583583
void i40e_fdir_check_and_reenable(struct i40e_pf *pf);
584584
int i40e_get_current_fd_count(struct i40e_pf *pf);
585+
int i40e_get_cur_guaranteed_fd_count(struct i40e_pf *pf);
585586
bool i40e_set_ntuple(struct i40e_pf *pf, netdev_features_t features);
586587
void i40e_set_ethtool_ops(struct net_device *netdev);
587588
struct i40e_mac_filter *i40e_add_filter(struct i40e_vsi *vsi,

drivers/net/ethernet/intel/i40e/i40e_debugfs.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1743,6 +1743,9 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
17431743
i40e_dbg_cmd_fd_ctrl(pf, I40E_FLAG_FD_ATR_ENABLED, false);
17441744
} else if (strncmp(cmd_buf, "fd-atr on", 9) == 0) {
17451745
i40e_dbg_cmd_fd_ctrl(pf, I40E_FLAG_FD_ATR_ENABLED, true);
1746+
} else if (strncmp(cmd_buf, "fd current cnt", 14) == 0) {
1747+
dev_info(&pf->pdev->dev, "FD current total filter count for this interface: %d\n",
1748+
i40e_get_current_fd_count(pf));
17461749
} else if (strncmp(cmd_buf, "lldp", 4) == 0) {
17471750
if (strncmp(&cmd_buf[5], "stop", 4) == 0) {
17481751
int ret;
@@ -1962,6 +1965,7 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
19621965
dev_info(&pf->pdev->dev, " rem fd_filter <dest q_index> <flex_off> <pctype> <dest_vsi> <dest_ctl> <fd_status> <cnt_index> <fd_id> <packet_len> <packet>\n");
19631966
dev_info(&pf->pdev->dev, " fd-atr off\n");
19641967
dev_info(&pf->pdev->dev, " fd-atr on\n");
1968+
dev_info(&pf->pdev->dev, " fd current cnt");
19651969
dev_info(&pf->pdev->dev, " lldp start\n");
19661970
dev_info(&pf->pdev->dev, " lldp stop\n");
19671971
dev_info(&pf->pdev->dev, " lldp get local\n");

drivers/net/ethernet/intel/i40e/i40e_lan_hmc.c

Lines changed: 196 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,194 @@ static struct i40e_context_ele i40e_hmc_rxq_ce_info[] = {
746746
{ 0 }
747747
};
748748

749+
/**
750+
* i40e_write_byte - replace HMC context byte
751+
* @hmc_bits: pointer to the HMC memory
752+
* @ce_info: a description of the struct to be read from
753+
* @src: the struct to be read from
754+
**/
755+
static void i40e_write_byte(u8 *hmc_bits,
756+
struct i40e_context_ele *ce_info,
757+
u8 *src)
758+
{
759+
u8 src_byte, dest_byte, mask;
760+
u8 *from, *dest;
761+
u16 shift_width;
762+
763+
/* copy from the next struct field */
764+
from = src + ce_info->offset;
765+
766+
/* prepare the bits and mask */
767+
shift_width = ce_info->lsb % 8;
768+
mask = ((u8)1 << ce_info->width) - 1;
769+
770+
src_byte = *from;
771+
src_byte &= mask;
772+
773+
/* shift to correct alignment */
774+
mask <<= shift_width;
775+
src_byte <<= shift_width;
776+
777+
/* get the current bits from the target bit string */
778+
dest = hmc_bits + (ce_info->lsb / 8);
779+
780+
memcpy(&dest_byte, dest, sizeof(dest_byte));
781+
782+
dest_byte &= ~mask; /* get the bits not changing */
783+
dest_byte |= src_byte; /* add in the new bits */
784+
785+
/* put it all back */
786+
memcpy(dest, &dest_byte, sizeof(dest_byte));
787+
}
788+
789+
/**
790+
* i40e_write_word - replace HMC context word
791+
* @hmc_bits: pointer to the HMC memory
792+
* @ce_info: a description of the struct to be read from
793+
* @src: the struct to be read from
794+
**/
795+
static void i40e_write_word(u8 *hmc_bits,
796+
struct i40e_context_ele *ce_info,
797+
u8 *src)
798+
{
799+
u16 src_word, mask;
800+
u8 *from, *dest;
801+
u16 shift_width;
802+
__le16 dest_word;
803+
804+
/* copy from the next struct field */
805+
from = src + ce_info->offset;
806+
807+
/* prepare the bits and mask */
808+
shift_width = ce_info->lsb % 8;
809+
mask = ((u16)1 << ce_info->width) - 1;
810+
811+
/* don't swizzle the bits until after the mask because the mask bits
812+
* will be in a different bit position on big endian machines
813+
*/
814+
src_word = *(u16 *)from;
815+
src_word &= mask;
816+
817+
/* shift to correct alignment */
818+
mask <<= shift_width;
819+
src_word <<= shift_width;
820+
821+
/* get the current bits from the target bit string */
822+
dest = hmc_bits + (ce_info->lsb / 8);
823+
824+
memcpy(&dest_word, dest, sizeof(dest_word));
825+
826+
dest_word &= ~(cpu_to_le16(mask)); /* get the bits not changing */
827+
dest_word |= cpu_to_le16(src_word); /* add in the new bits */
828+
829+
/* put it all back */
830+
memcpy(dest, &dest_word, sizeof(dest_word));
831+
}
832+
833+
/**
834+
* i40e_write_dword - replace HMC context dword
835+
* @hmc_bits: pointer to the HMC memory
836+
* @ce_info: a description of the struct to be read from
837+
* @src: the struct to be read from
838+
**/
839+
static void i40e_write_dword(u8 *hmc_bits,
840+
struct i40e_context_ele *ce_info,
841+
u8 *src)
842+
{
843+
u32 src_dword, mask;
844+
u8 *from, *dest;
845+
u16 shift_width;
846+
__le32 dest_dword;
847+
848+
/* copy from the next struct field */
849+
from = src + ce_info->offset;
850+
851+
/* prepare the bits and mask */
852+
shift_width = ce_info->lsb % 8;
853+
854+
/* if the field width is exactly 32 on an x86 machine, then the shift
855+
* operation will not work because the SHL instructions count is masked
856+
* to 5 bits so the shift will do nothing
857+
*/
858+
if (ce_info->width < 32)
859+
mask = ((u32)1 << ce_info->width) - 1;
860+
else
861+
mask = -1;
862+
863+
/* don't swizzle the bits until after the mask because the mask bits
864+
* will be in a different bit position on big endian machines
865+
*/
866+
src_dword = *(u32 *)from;
867+
src_dword &= mask;
868+
869+
/* shift to correct alignment */
870+
mask <<= shift_width;
871+
src_dword <<= shift_width;
872+
873+
/* get the current bits from the target bit string */
874+
dest = hmc_bits + (ce_info->lsb / 8);
875+
876+
memcpy(&dest_dword, dest, sizeof(dest_dword));
877+
878+
dest_dword &= ~(cpu_to_le32(mask)); /* get the bits not changing */
879+
dest_dword |= cpu_to_le32(src_dword); /* add in the new bits */
880+
881+
/* put it all back */
882+
memcpy(dest, &dest_dword, sizeof(dest_dword));
883+
}
884+
885+
/**
886+
* i40e_write_qword - replace HMC context qword
887+
* @hmc_bits: pointer to the HMC memory
888+
* @ce_info: a description of the struct to be read from
889+
* @src: the struct to be read from
890+
**/
891+
static void i40e_write_qword(u8 *hmc_bits,
892+
struct i40e_context_ele *ce_info,
893+
u8 *src)
894+
{
895+
u64 src_qword, mask;
896+
u8 *from, *dest;
897+
u16 shift_width;
898+
__le64 dest_qword;
899+
900+
/* copy from the next struct field */
901+
from = src + ce_info->offset;
902+
903+
/* prepare the bits and mask */
904+
shift_width = ce_info->lsb % 8;
905+
906+
/* if the field width is exactly 64 on an x86 machine, then the shift
907+
* operation will not work because the SHL instructions count is masked
908+
* to 6 bits so the shift will do nothing
909+
*/
910+
if (ce_info->width < 64)
911+
mask = ((u64)1 << ce_info->width) - 1;
912+
else
913+
mask = -1;
914+
915+
/* don't swizzle the bits until after the mask because the mask bits
916+
* will be in a different bit position on big endian machines
917+
*/
918+
src_qword = *(u64 *)from;
919+
src_qword &= mask;
920+
921+
/* shift to correct alignment */
922+
mask <<= shift_width;
923+
src_qword <<= shift_width;
924+
925+
/* get the current bits from the target bit string */
926+
dest = hmc_bits + (ce_info->lsb / 8);
927+
928+
memcpy(&dest_qword, dest, sizeof(dest_qword));
929+
930+
dest_qword &= ~(cpu_to_le64(mask)); /* get the bits not changing */
931+
dest_qword |= cpu_to_le64(src_qword); /* add in the new bits */
932+
933+
/* put it all back */
934+
memcpy(dest, &dest_qword, sizeof(dest_qword));
935+
}
936+
749937
/**
750938
* i40e_clear_hmc_context - zero out the HMC context bits
751939
* @hw: the hardware struct
@@ -772,71 +960,28 @@ static i40e_status i40e_set_hmc_context(u8 *context_bytes,
772960
struct i40e_context_ele *ce_info,
773961
u8 *dest)
774962
{
775-
u16 shift_width;
776-
u64 bitfield;
777-
u8 hi_byte;
778-
u8 hi_mask;
779-
u64 t_bits;
780-
u64 mask;
781-
u8 *p;
782963
int f;
783964

784965
for (f = 0; ce_info[f].width != 0; f++) {
785-
/* clear out the field */
786-
bitfield = 0;
787966

788-
/* copy from the next struct field */
789-
p = dest + ce_info[f].offset;
967+
/* we have to deal with each element of the HMC using the
968+
* correct size so that we are correct regardless of the
969+
* endianness of the machine
970+
*/
790971
switch (ce_info[f].size_of) {
791972
case 1:
792-
bitfield = *p;
973+
i40e_write_byte(context_bytes, &ce_info[f], dest);
793974
break;
794975
case 2:
795-
bitfield = cpu_to_le16(*(u16 *)p);
976+
i40e_write_word(context_bytes, &ce_info[f], dest);
796977
break;
797978
case 4:
798-
bitfield = cpu_to_le32(*(u32 *)p);
979+
i40e_write_dword(context_bytes, &ce_info[f], dest);
799980
break;
800981
case 8:
801-
bitfield = cpu_to_le64(*(u64 *)p);
982+
i40e_write_qword(context_bytes, &ce_info[f], dest);
802983
break;
803984
}
804-
805-
/* prepare the bits and mask */
806-
shift_width = ce_info[f].lsb % 8;
807-
mask = ((u64)1 << ce_info[f].width) - 1;
808-
809-
/* save upper bytes for special case */
810-
hi_mask = (u8)((mask >> 56) & 0xff);
811-
hi_byte = (u8)((bitfield >> 56) & 0xff);
812-
813-
/* shift to correct alignment */
814-
mask <<= shift_width;
815-
bitfield <<= shift_width;
816-
817-
/* get the current bits from the target bit string */
818-
p = context_bytes + (ce_info[f].lsb / 8);
819-
memcpy(&t_bits, p, sizeof(u64));
820-
821-
t_bits &= ~mask; /* get the bits not changing */
822-
t_bits |= bitfield; /* add in the new bits */
823-
824-
/* put it all back */
825-
memcpy(p, &t_bits, sizeof(u64));
826-
827-
/* deal with the special case if needed
828-
* example: 62 bit field that starts in bit 5 of first byte
829-
* will overlap 3 bits into byte 9
830-
*/
831-
if ((shift_width + ce_info[f].width) > 64) {
832-
u8 byte;
833-
834-
hi_mask >>= (8 - shift_width);
835-
hi_byte >>= (8 - shift_width);
836-
byte = p[8] & ~hi_mask; /* get the bits not changing */
837-
byte |= hi_byte; /* add in the new bits */
838-
p[8] = byte; /* put it back */
839-
}
840985
}
841986

842987
return 0;

drivers/net/ethernet/intel/i40e/i40e_lan_hmc.h

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,22 @@ struct i40e_hw;
3232

3333
/* HMC element context information */
3434

35-
/* Rx queue context data */
35+
/* Rx queue context data
36+
*
37+
* The sizes of the variables may be larger than needed due to crossing byte
38+
* boundaries. If we do not have the width of the variable set to the correct
39+
* size then we could end up shifting bits off the top of the variable when the
40+
* variable is at the top of a byte and crosses over into the next byte.
41+
*/
3642
struct i40e_hmc_obj_rxq {
3743
u16 head;
38-
u8 cpuid;
44+
u16 cpuid; /* bigger than needed, see above for reason */
3945
u64 base;
4046
u16 qlen;
4147
#define I40E_RXQ_CTX_DBUFF_SHIFT 7
42-
u8 dbuff;
48+
u16 dbuff; /* bigger than needed, see above for reason */
4349
#define I40E_RXQ_CTX_HBUFF_SHIFT 6
44-
u8 hbuff;
50+
u16 hbuff; /* bigger than needed, see above for reason */
4551
u8 dtype;
4652
u8 dsize;
4753
u8 crcstrip;
@@ -50,16 +56,22 @@ struct i40e_hmc_obj_rxq {
5056
u8 hsplit_0;
5157
u8 hsplit_1;
5258
u8 showiv;
53-
u16 rxmax;
59+
u32 rxmax; /* bigger than needed, see above for reason */
5460
u8 tphrdesc_ena;
5561
u8 tphwdesc_ena;
5662
u8 tphdata_ena;
5763
u8 tphhead_ena;
58-
u8 lrxqthresh;
64+
u16 lrxqthresh; /* bigger than needed, see above for reason */
5965
u8 prefena; /* NOTE: normally must be set to 1 at init */
6066
};
6167

62-
/* Tx queue context data */
68+
/* Tx queue context data
69+
*
70+
* The sizes of the variables may be larger than needed due to crossing byte
71+
* boundaries. If we do not have the width of the variable set to the correct
72+
* size then we could end up shifting bits off the top of the variable when the
73+
* variable is at the top of a byte and crosses over into the next byte.
74+
*/
6375
struct i40e_hmc_obj_txq {
6476
u16 head;
6577
u8 new_context;
@@ -69,7 +81,7 @@ struct i40e_hmc_obj_txq {
6981
u8 fd_ena;
7082
u8 alt_vlan_ena;
7183
u16 thead_wb;
72-
u16 cpuid;
84+
u8 cpuid;
7385
u8 head_wb_ena;
7486
u16 qlen;
7587
u8 tphrdesc_ena;

0 commit comments

Comments
 (0)