Skip to content

Commit 90a5a89

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) Validate iov ranges before feeding them into iov_iter_init(), from Al Viro. 2) We changed copy_from_msghdr_from_user() to zero out the msg_namelen is a NULL pointer is given for the msg_name. Do the same in the compat code too. From Catalin Marinas. 3) Fix partially initialized tuples in netfilter conntrack helper, from Ian Wilson. 4) Missing continue; statement in nft_hash walker can lead to crashes, from Herbert Xu. 5) tproxy_tg6_check looks for IP6T_INV_PROTO in ->flags instead of ->invflags, fix from Pablo Neira Ayuso. 6) Incorrect memory account of TCP FINs can result in negative socket memory accounting values. Fix from Josh Hunt. 7) Don't allow virtual functions to enable VLAN promiscuous mode in be2net driver, from Vasundhara Volam. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: netfilter: nft_compat: set IP6T_F_PROTO flag if protocol is set cx82310_eth: wait for firmware to become ready net: validate the range we feed to iov_iter_init() in sys_sendto/sys_recvfrom net: compat: Update get_compat_msghdr() to match copy_msghdr_from_user() behaviour be2net: use PCI MMIO read instead of config read for errors be2net: restrict MODIFY_EQ_DELAY cmd to a max of 8 EQs be2net: Prevent VFs from enabling VLAN promiscuous mode tcp: fix tcp fin memory accounting ipv6: fix backtracking for throw routes net: ethernet: pcnet32: Setup the SRAM and NOUFLO on Am79C97{3, 5} ipv6: call ipv6_proxy_select_ident instead of ipv6_select_ident in udp6_ufo_fragment netfilter: xt_TPROXY: fix invflags check in tproxy_tg6_check() netfilter: restore rule tracing via nfnetlink_log netfilter: nf_tables: allow to change chain policy without hook if it exists netfilter: Fix potential crash in nft_hash walker netfilter: Zero the tuple in nfnl_cthelper_parse_tuple()
2 parents d504961 + c0e41fa commit 90a5a89

File tree

21 files changed

+238
-75
lines changed

21 files changed

+238
-75
lines changed

drivers/net/ethernet/amd/pcnet32.c

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,7 +1543,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
15431543
{
15441544
struct pcnet32_private *lp;
15451545
int i, media;
1546-
int fdx, mii, fset, dxsuflo;
1546+
int fdx, mii, fset, dxsuflo, sram;
15471547
int chip_version;
15481548
char *chipname;
15491549
struct net_device *dev;
@@ -1580,7 +1580,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
15801580
}
15811581

15821582
/* initialize variables */
1583-
fdx = mii = fset = dxsuflo = 0;
1583+
fdx = mii = fset = dxsuflo = sram = 0;
15841584
chip_version = (chip_version >> 12) & 0xffff;
15851585

15861586
switch (chip_version) {
@@ -1613,6 +1613,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
16131613
chipname = "PCnet/FAST III 79C973"; /* PCI */
16141614
fdx = 1;
16151615
mii = 1;
1616+
sram = 1;
16161617
break;
16171618
case 0x2626:
16181619
chipname = "PCnet/Home 79C978"; /* PCI */
@@ -1636,6 +1637,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
16361637
chipname = "PCnet/FAST III 79C975"; /* PCI */
16371638
fdx = 1;
16381639
mii = 1;
1640+
sram = 1;
16391641
break;
16401642
case 0x2628:
16411643
chipname = "PCnet/PRO 79C976";
@@ -1664,6 +1666,31 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
16641666
dxsuflo = 1;
16651667
}
16661668

1669+
/*
1670+
* The Am79C973/Am79C975 controllers come with 12K of SRAM
1671+
* which we can use for the Tx/Rx buffers but most importantly,
1672+
* the use of SRAM allow us to use the BCR18:NOUFLO bit to avoid
1673+
* Tx fifo underflows.
1674+
*/
1675+
if (sram) {
1676+
/*
1677+
* The SRAM is being configured in two steps. First we
1678+
* set the SRAM size in the BCR25:SRAM_SIZE bits. According
1679+
* to the datasheet, each bit corresponds to a 512-byte
1680+
* page so we can have at most 24 pages. The SRAM_SIZE
1681+
* holds the value of the upper 8 bits of the 16-bit SRAM size.
1682+
* The low 8-bits start at 0x00 and end at 0xff. So the
1683+
* address range is from 0x0000 up to 0x17ff. Therefore,
1684+
* the SRAM_SIZE is set to 0x17. The next step is to set
1685+
* the BCR26:SRAM_BND midway through so the Tx and Rx
1686+
* buffers can share the SRAM equally.
1687+
*/
1688+
a->write_bcr(ioaddr, 25, 0x17);
1689+
a->write_bcr(ioaddr, 26, 0xc);
1690+
/* And finally enable the NOUFLO bit */
1691+
a->write_bcr(ioaddr, 18, a->read_bcr(ioaddr, 18) | (1 << 11));
1692+
}
1693+
16671694
dev = alloc_etherdev(sizeof(*lp));
16681695
if (!dev) {
16691696
ret = -ENOMEM;

drivers/net/ethernet/emulex/benet/be.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ struct be_vf_cfg {
354354
u16 vlan_tag;
355355
u32 tx_rate;
356356
u32 plink_tracking;
357+
u32 privileges;
357358
};
358359

359360
enum vf_state {
@@ -423,6 +424,7 @@ struct be_adapter {
423424

424425
u8 __iomem *csr; /* CSR BAR used only for BE2/3 */
425426
u8 __iomem *db; /* Door Bell */
427+
u8 __iomem *pcicfg; /* On SH,BEx only. Shadow of PCI config space */
426428

427429
struct mutex mbox_lock; /* For serializing mbox cmds to BE card */
428430
struct be_dma_mem mbox_mem;

drivers/net/ethernet/emulex/benet/be_cmds.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,23 +1902,19 @@ int be_cmd_modify_eqd(struct be_adapter *adapter, struct be_set_eqd *set_eqd,
19021902
{
19031903
int num_eqs, i = 0;
19041904

1905-
if (lancer_chip(adapter) && num > 8) {
1906-
while (num) {
1907-
num_eqs = min(num, 8);
1908-
__be_cmd_modify_eqd(adapter, &set_eqd[i], num_eqs);
1909-
i += num_eqs;
1910-
num -= num_eqs;
1911-
}
1912-
} else {
1913-
__be_cmd_modify_eqd(adapter, set_eqd, num);
1905+
while (num) {
1906+
num_eqs = min(num, 8);
1907+
__be_cmd_modify_eqd(adapter, &set_eqd[i], num_eqs);
1908+
i += num_eqs;
1909+
num -= num_eqs;
19141910
}
19151911

19161912
return 0;
19171913
}
19181914

19191915
/* Uses sycnhronous mcc */
19201916
int be_cmd_vlan_config(struct be_adapter *adapter, u32 if_id, u16 *vtag_array,
1921-
u32 num)
1917+
u32 num, u32 domain)
19221918
{
19231919
struct be_mcc_wrb *wrb;
19241920
struct be_cmd_req_vlan_config *req;
@@ -1936,6 +1932,7 @@ int be_cmd_vlan_config(struct be_adapter *adapter, u32 if_id, u16 *vtag_array,
19361932
be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
19371933
OPCODE_COMMON_NTWK_VLAN_CONFIG, sizeof(*req),
19381934
wrb, NULL);
1935+
req->hdr.domain = domain;
19391936

19401937
req->interface_id = if_id;
19411938
req->untagged = BE_IF_FLAGS_UNTAGGED & be_if_cap_flags(adapter) ? 1 : 0;

drivers/net/ethernet/emulex/benet/be_cmds.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2256,7 +2256,7 @@ int lancer_cmd_get_pport_stats(struct be_adapter *adapter,
22562256
int be_cmd_get_fw_ver(struct be_adapter *adapter);
22572257
int be_cmd_modify_eqd(struct be_adapter *adapter, struct be_set_eqd *, int num);
22582258
int be_cmd_vlan_config(struct be_adapter *adapter, u32 if_id, u16 *vtag_array,
2259-
u32 num);
2259+
u32 num, u32 domain);
22602260
int be_cmd_rx_filter(struct be_adapter *adapter, u32 flags, u32 status);
22612261
int be_cmd_set_flow_control(struct be_adapter *adapter, u32 tx_fc, u32 rx_fc);
22622262
int be_cmd_get_flow_control(struct be_adapter *adapter, u32 *tx_fc, u32 *rx_fc);

drivers/net/ethernet/emulex/benet/be_main.c

Lines changed: 98 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ static int be_vid_config(struct be_adapter *adapter)
11711171
for_each_set_bit(i, adapter->vids, VLAN_N_VID)
11721172
vids[num++] = cpu_to_le16(i);
11731173

1174-
status = be_cmd_vlan_config(adapter, adapter->if_handle, vids, num);
1174+
status = be_cmd_vlan_config(adapter, adapter->if_handle, vids, num, 0);
11751175
if (status) {
11761176
dev_err(dev, "Setting HW VLAN filtering failed\n");
11771177
/* Set to VLAN promisc mode as setting VLAN filter failed */
@@ -1380,11 +1380,67 @@ static int be_get_vf_config(struct net_device *netdev, int vf,
13801380
return 0;
13811381
}
13821382

1383+
static int be_set_vf_tvt(struct be_adapter *adapter, int vf, u16 vlan)
1384+
{
1385+
struct be_vf_cfg *vf_cfg = &adapter->vf_cfg[vf];
1386+
u16 vids[BE_NUM_VLANS_SUPPORTED];
1387+
int vf_if_id = vf_cfg->if_handle;
1388+
int status;
1389+
1390+
/* Enable Transparent VLAN Tagging */
1391+
status = be_cmd_set_hsw_config(adapter, vlan, vf + 1, vf_if_id, 0);
1392+
if (status)
1393+
return status;
1394+
1395+
/* Clear pre-programmed VLAN filters on VF if any, if TVT is enabled */
1396+
vids[0] = 0;
1397+
status = be_cmd_vlan_config(adapter, vf_if_id, vids, 1, vf + 1);
1398+
if (!status)
1399+
dev_info(&adapter->pdev->dev,
1400+
"Cleared guest VLANs on VF%d", vf);
1401+
1402+
/* After TVT is enabled, disallow VFs to program VLAN filters */
1403+
if (vf_cfg->privileges & BE_PRIV_FILTMGMT) {
1404+
status = be_cmd_set_fn_privileges(adapter, vf_cfg->privileges &
1405+
~BE_PRIV_FILTMGMT, vf + 1);
1406+
if (!status)
1407+
vf_cfg->privileges &= ~BE_PRIV_FILTMGMT;
1408+
}
1409+
return 0;
1410+
}
1411+
1412+
static int be_clear_vf_tvt(struct be_adapter *adapter, int vf)
1413+
{
1414+
struct be_vf_cfg *vf_cfg = &adapter->vf_cfg[vf];
1415+
struct device *dev = &adapter->pdev->dev;
1416+
int status;
1417+
1418+
/* Reset Transparent VLAN Tagging. */
1419+
status = be_cmd_set_hsw_config(adapter, BE_RESET_VLAN_TAG_ID, vf + 1,
1420+
vf_cfg->if_handle, 0);
1421+
if (status)
1422+
return status;
1423+
1424+
/* Allow VFs to program VLAN filtering */
1425+
if (!(vf_cfg->privileges & BE_PRIV_FILTMGMT)) {
1426+
status = be_cmd_set_fn_privileges(adapter, vf_cfg->privileges |
1427+
BE_PRIV_FILTMGMT, vf + 1);
1428+
if (!status) {
1429+
vf_cfg->privileges |= BE_PRIV_FILTMGMT;
1430+
dev_info(dev, "VF%d: FILTMGMT priv enabled", vf);
1431+
}
1432+
}
1433+
1434+
dev_info(dev,
1435+
"Disable/re-enable i/f in VM to clear Transparent VLAN tag");
1436+
return 0;
1437+
}
1438+
13831439
static int be_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos)
13841440
{
13851441
struct be_adapter *adapter = netdev_priv(netdev);
13861442
struct be_vf_cfg *vf_cfg = &adapter->vf_cfg[vf];
1387-
int status = 0;
1443+
int status;
13881444

13891445
if (!sriov_enabled(adapter))
13901446
return -EPERM;
@@ -1394,24 +1450,19 @@ static int be_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos)
13941450

13951451
if (vlan || qos) {
13961452
vlan |= qos << VLAN_PRIO_SHIFT;
1397-
if (vf_cfg->vlan_tag != vlan)
1398-
status = be_cmd_set_hsw_config(adapter, vlan, vf + 1,
1399-
vf_cfg->if_handle, 0);
1453+
status = be_set_vf_tvt(adapter, vf, vlan);
14001454
} else {
1401-
/* Reset Transparent Vlan Tagging. */
1402-
status = be_cmd_set_hsw_config(adapter, BE_RESET_VLAN_TAG_ID,
1403-
vf + 1, vf_cfg->if_handle, 0);
1455+
status = be_clear_vf_tvt(adapter, vf);
14041456
}
14051457

14061458
if (status) {
14071459
dev_err(&adapter->pdev->dev,
1408-
"VLAN %d config on VF %d failed : %#x\n", vlan,
1409-
vf, status);
1460+
"VLAN %d config on VF %d failed : %#x\n", vlan, vf,
1461+
status);
14101462
return be_cmd_status(status);
14111463
}
14121464

14131465
vf_cfg->vlan_tag = vlan;
1414-
14151466
return 0;
14161467
}
14171468

@@ -2772,14 +2823,12 @@ void be_detect_error(struct be_adapter *adapter)
27722823
}
27732824
}
27742825
} else {
2775-
pci_read_config_dword(adapter->pdev,
2776-
PCICFG_UE_STATUS_LOW, &ue_lo);
2777-
pci_read_config_dword(adapter->pdev,
2778-
PCICFG_UE_STATUS_HIGH, &ue_hi);
2779-
pci_read_config_dword(adapter->pdev,
2780-
PCICFG_UE_STATUS_LOW_MASK, &ue_lo_mask);
2781-
pci_read_config_dword(adapter->pdev,
2782-
PCICFG_UE_STATUS_HI_MASK, &ue_hi_mask);
2826+
ue_lo = ioread32(adapter->pcicfg + PCICFG_UE_STATUS_LOW);
2827+
ue_hi = ioread32(adapter->pcicfg + PCICFG_UE_STATUS_HIGH);
2828+
ue_lo_mask = ioread32(adapter->pcicfg +
2829+
PCICFG_UE_STATUS_LOW_MASK);
2830+
ue_hi_mask = ioread32(adapter->pcicfg +
2831+
PCICFG_UE_STATUS_HI_MASK);
27832832

27842833
ue_lo = (ue_lo & ~ue_lo_mask);
27852834
ue_hi = (ue_hi & ~ue_hi_mask);
@@ -3339,18 +3388,14 @@ static int be_if_create(struct be_adapter *adapter, u32 *if_handle,
33393388
u32 cap_flags, u32 vf)
33403389
{
33413390
u32 en_flags;
3342-
int status;
33433391

33443392
en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST |
33453393
BE_IF_FLAGS_MULTICAST | BE_IF_FLAGS_PASS_L3L4_ERRORS |
33463394
BE_IF_FLAGS_RSS;
33473395

33483396
en_flags &= cap_flags;
33493397

3350-
status = be_cmd_if_create(adapter, cap_flags, en_flags,
3351-
if_handle, vf);
3352-
3353-
return status;
3398+
return be_cmd_if_create(adapter, cap_flags, en_flags, if_handle, vf);
33543399
}
33553400

33563401
static int be_vfs_if_create(struct be_adapter *adapter)
@@ -3368,8 +3413,13 @@ static int be_vfs_if_create(struct be_adapter *adapter)
33683413
if (!BE3_chip(adapter)) {
33693414
status = be_cmd_get_profile_config(adapter, &res,
33703415
vf + 1);
3371-
if (!status)
3416+
if (!status) {
33723417
cap_flags = res.if_cap_flags;
3418+
/* Prevent VFs from enabling VLAN promiscuous
3419+
* mode
3420+
*/
3421+
cap_flags &= ~BE_IF_FLAGS_VLAN_PROMISCUOUS;
3422+
}
33733423
}
33743424

33753425
status = be_if_create(adapter, &vf_cfg->if_handle,
@@ -3403,7 +3453,6 @@ static int be_vf_setup(struct be_adapter *adapter)
34033453
struct device *dev = &adapter->pdev->dev;
34043454
struct be_vf_cfg *vf_cfg;
34053455
int status, old_vfs, vf;
3406-
u32 privileges;
34073456

34083457
old_vfs = pci_num_vf(adapter->pdev);
34093458

@@ -3433,15 +3482,18 @@ static int be_vf_setup(struct be_adapter *adapter)
34333482

34343483
for_all_vfs(adapter, vf_cfg, vf) {
34353484
/* Allow VFs to programs MAC/VLAN filters */
3436-
status = be_cmd_get_fn_privileges(adapter, &privileges, vf + 1);
3437-
if (!status && !(privileges & BE_PRIV_FILTMGMT)) {
3485+
status = be_cmd_get_fn_privileges(adapter, &vf_cfg->privileges,
3486+
vf + 1);
3487+
if (!status && !(vf_cfg->privileges & BE_PRIV_FILTMGMT)) {
34383488
status = be_cmd_set_fn_privileges(adapter,
3439-
privileges |
3489+
vf_cfg->privileges |
34403490
BE_PRIV_FILTMGMT,
34413491
vf + 1);
3442-
if (!status)
3492+
if (!status) {
3493+
vf_cfg->privileges |= BE_PRIV_FILTMGMT;
34433494
dev_info(dev, "VF%d has FILTMGMT privilege\n",
34443495
vf);
3496+
}
34453497
}
34463498

34473499
/* Allow full available bandwidth */
@@ -4820,24 +4872,37 @@ static int be_roce_map_pci_bars(struct be_adapter *adapter)
48204872

48214873
static int be_map_pci_bars(struct be_adapter *adapter)
48224874
{
4875+
struct pci_dev *pdev = adapter->pdev;
48234876
u8 __iomem *addr;
48244877

48254878
if (BEx_chip(adapter) && be_physfn(adapter)) {
4826-
adapter->csr = pci_iomap(adapter->pdev, 2, 0);
4879+
adapter->csr = pci_iomap(pdev, 2, 0);
48274880
if (!adapter->csr)
48284881
return -ENOMEM;
48294882
}
48304883

4831-
addr = pci_iomap(adapter->pdev, db_bar(adapter), 0);
4884+
addr = pci_iomap(pdev, db_bar(adapter), 0);
48324885
if (!addr)
48334886
goto pci_map_err;
48344887
adapter->db = addr;
48354888

4889+
if (skyhawk_chip(adapter) || BEx_chip(adapter)) {
4890+
if (be_physfn(adapter)) {
4891+
/* PCICFG is the 2nd BAR in BE2 */
4892+
addr = pci_iomap(pdev, BE2_chip(adapter) ? 1 : 0, 0);
4893+
if (!addr)
4894+
goto pci_map_err;
4895+
adapter->pcicfg = addr;
4896+
} else {
4897+
adapter->pcicfg = adapter->db + SRIOV_VF_PCICFG_OFFSET;
4898+
}
4899+
}
4900+
48364901
be_roce_map_pci_bars(adapter);
48374902
return 0;
48384903

48394904
pci_map_err:
4840-
dev_err(&adapter->pdev->dev, "Error in mapping PCI BARs\n");
4905+
dev_err(&pdev->dev, "Error in mapping PCI BARs\n");
48414906
be_unmap_pci_bars(adapter);
48424907
return -ENOMEM;
48434908
}

0 commit comments

Comments
 (0)