Commit 37d4b3fd authored by Vladimir Oltean's avatar Vladimir Oltean Committed by David S. Miller

net: enetc: catch negative return code from enetc_pf_to_port()

After the refactoring introduced in commit 87614b93 ("net: enetc:
create a common enetc_pf_to_port helper"), enetc_pf_to_port was coded up
to return -1 in case the passed PCIe device does not have a recognized
BDF.

Make sure the -1 value is checked by the callers, to appease static
checkers.
Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b0f6c9ac
......@@ -465,8 +465,13 @@ static int enetc_streamid_hw_set(struct enetc_ndev_priv *priv,
struct streamid_conf *si_conf;
u16 data_size;
dma_addr_t dma;
int port;
int err;
port = enetc_pf_to_port(priv->si->pdev);
if (port < 0)
return -EINVAL;
if (sid->index >= priv->psfp_cap.max_streamid)
return -EINVAL;
......@@ -499,7 +504,7 @@ static int enetc_streamid_hw_set(struct enetc_ndev_priv *priv,
si_conf = &cbd.sid_set;
/* Only one port supported for one entry, set itself */
si_conf->iports = cpu_to_le32(1 << enetc_pf_to_port(priv->si->pdev));
si_conf->iports = cpu_to_le32(1 << port);
si_conf->id_type = 1;
si_conf->oui[2] = 0x0;
si_conf->oui[1] = 0x80;
......@@ -524,7 +529,7 @@ static int enetc_streamid_hw_set(struct enetc_ndev_priv *priv,
si_conf->en = 0x80;
si_conf->stream_handle = cpu_to_le32(sid->handle);
si_conf->iports = cpu_to_le32(1 << enetc_pf_to_port(priv->si->pdev));
si_conf->iports = cpu_to_le32(1 << port);
si_conf->id_type = sid->filtertype;
si_conf->oui[2] = 0x0;
si_conf->oui[1] = 0x80;
......@@ -567,6 +572,11 @@ static int enetc_streamfilter_hw_set(struct enetc_ndev_priv *priv,
{
struct enetc_cbd cbd = {.cmd = 0};
struct sfi_conf *sfi_config;
int port;
port = enetc_pf_to_port(priv->si->pdev);
if (port < 0)
return -EINVAL;
cbd.index = cpu_to_le16(sfi->index);
cbd.cls = BDCR_CMD_STREAM_FILTER;
......@@ -586,8 +596,7 @@ static int enetc_streamfilter_hw_set(struct enetc_ndev_priv *priv,
}
sfi_config->sg_inst_table_index = cpu_to_le16(sfi->gate_id);
sfi_config->input_ports =
cpu_to_le32(1 << enetc_pf_to_port(priv->si->pdev));
sfi_config->input_ports = cpu_to_le32(1 << port);
/* The priority value which may be matched against the
* frame’s priority value to determine a match for this entry.
......@@ -1548,7 +1557,7 @@ int enetc_setup_tc_psfp(struct net_device *ndev, void *type_data)
{
struct enetc_ndev_priv *priv = netdev_priv(ndev);
struct flow_block_offload *f = type_data;
int err;
int port, err;
err = flow_block_cb_setup_simple(f, &enetc_block_cb_list,
enetc_setup_tc_block_cb,
......@@ -1558,10 +1567,18 @@ int enetc_setup_tc_psfp(struct net_device *ndev, void *type_data)
switch (f->command) {
case FLOW_BLOCK_BIND:
set_bit(enetc_pf_to_port(priv->si->pdev), &epsfp.dev_bitmap);
port = enetc_pf_to_port(priv->si->pdev);
if (port < 0)
return -EINVAL;
set_bit(port, &epsfp.dev_bitmap);
break;
case FLOW_BLOCK_UNBIND:
clear_bit(enetc_pf_to_port(priv->si->pdev), &epsfp.dev_bitmap);
port = enetc_pf_to_port(priv->si->pdev);
if (port < 0)
return -EINVAL;
clear_bit(port, &epsfp.dev_bitmap);
if (!epsfp.dev_bitmap)
clean_psfp_all();
break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment