All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: rsaladi2@marvell.com
Cc: kernel-janitors@vger.kernel.org
Subject: [bug report] octeontx2-pf: Ntuple filters support for VF netdev
Date: Tue, 30 Nov 2021 13:43:58 +0300	[thread overview]
Message-ID: <20211130104358.GF5827@kili> (raw)

Hello Rakesh Babu,

The patch 3cffaed2136c: "octeontx2-pf: Ntuple filters support for VF
netdev" from Aug 17, 2021, leads to the following Smatch static
checker warning:

    drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c:1247 rvu_mbox_handler_npc_install_flow()
    error: uninitialized symbol 'nixlf'.

    drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c:392 npc_get_default_entry_action()
    error: uninitialized symbol 'nixlf'.

drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c
    1154 int rvu_mbox_handler_npc_install_flow(struct rvu *rvu,
    1155                                       struct npc_install_flow_req *req,
    1156                                       struct npc_install_flow_rsp *rsp)
    1157 {
    1158         bool from_vf = !!(req->hdr.pcifunc & RVU_PFVF_FUNC_MASK);
    1159         struct rvu_switch *rswitch = &rvu->rswitch;
    1160         int blkaddr, nixlf, err;
                              ^^^^^
    1161         struct rvu_pfvf *pfvf;
    1162         bool pf_set_vfs_mac = false;
    1163         bool enable = true;
    1164         u16 target;
    1165 
    1166         blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NPC, 0);
    1167         if (blkaddr < 0) {
    1168                 dev_err(rvu->dev, "%s: NPC block not implemented\n", __func__);
    1169                 return NPC_MCAM_INVALID_REQ;
    1170         }
    1171 
    1172         if (!is_npc_interface_valid(rvu, req->intf))
    1173                 return NPC_FLOW_INTF_INVALID;
    1174 
    1175         if (from_vf && req->default_rule)
    1176                 return NPC_FLOW_VF_PERM_DENIED;
    1177 
    1178         /* Each PF/VF info is maintained in struct rvu_pfvf.
    1179          * rvu_pfvf for the target PF/VF needs to be retrieved
    1180          * hence modify pcifunc accordingly.
    1181          */
    1182 
    1183         /* AF installing for a PF/VF */
    1184         if (!req->hdr.pcifunc)
    1185                 target = req->vf;
    1186         /* PF installing for its VF */
    1187         else if (!from_vf && req->vf) {
    1188                 target = (req->hdr.pcifunc & ~RVU_PFVF_FUNC_MASK) | req->vf;
    1189                 pf_set_vfs_mac = req->default_rule &&
    1190                                 (req->features & BIT_ULL(NPC_DMAC));
    1191         }
    1192         /* msg received from PF/VF */
    1193         else
    1194                 target = req->hdr.pcifunc;
    1195 
    1196         /* ignore chan_mask in case pf func is not AF, revisit later */
    1197         if (!is_pffunc_af(req->hdr.pcifunc))
    1198                 req->chan_mask = 0xFFF;
    1199 
    1200         err = npc_check_unsupported_flows(rvu, req->features, req->intf);
    1201         if (err)
    1202                 return NPC_FLOW_NOT_SUPPORTED;
    1203 
    1204         pfvf = rvu_get_pfvf(rvu, target);
    1205 
    1206         /* PF installing for its VF */
    1207         if (req->hdr.pcifunc && !from_vf && req->vf)
    1208                 set_bit(PF_SET_VF_CFG, &pfvf->flags);
    1209 
    1210         /* update req destination mac addr */
    1211         if ((req->features & BIT_ULL(NPC_DMAC)) && is_npc_intf_rx(req->intf) &&
    1212             is_zero_ether_addr(req->packet.dmac)) {
    1213                 ether_addr_copy(req->packet.dmac, pfvf->mac_addr);
    1214                 eth_broadcast_addr((u8 *)&req->mask.dmac);
    1215         }
    1216 
    1217         /* Proceed if NIXLF is attached or not for TX rules */
    1218         err = nix_get_nixlf(rvu, target, &nixlf, NULL);
    1219         if (err && is_npc_intf_rx(req->intf) && !pf_set_vfs_mac)
    1220                 return NPC_FLOW_NO_NIXLF;

If nix_get_nixlf() fails then "nixlf" is not necessarily initialized and
then if is_npc_intf_rx() is true or pf_set_vfs_mac is false then this
will not return.

    1221 
    1222         /* don't enable rule when nixlf not attached or initialized */
    1223         if (!(is_nixlf_attached(rvu, target) &&
    1224               test_bit(NIXLF_INITIALIZED, &pfvf->flags)))
    1225                 enable = false;
    1226 
    1227         /* Packets reaching NPC in Tx path implies that a
    1228          * NIXLF is properly setup and transmitting.
    1229          * Hence rules can be enabled for Tx.
    1230          */
    1231         if (is_npc_intf_tx(req->intf))
    1232                 enable = true;
    1233 
    1234         /* Do not allow requests from uninitialized VFs */
    1235         if (from_vf && !enable)
    1236                 return NPC_FLOW_VF_NOT_INIT;
    1237 
    1238         /* PF sets VF mac & VF NIXLF is not attached, update the mac addr */
    1239         if (pf_set_vfs_mac && !enable) {
    1240                 ether_addr_copy(pfvf->default_mac, req->packet.dmac);
    1241                 ether_addr_copy(pfvf->mac_addr, req->packet.dmac);
    1242                 set_bit(PF_SET_VF_MAC, &pfvf->flags);
    1243                 return 0;
    1244         }
    1245 
    1246         mutex_lock(&rswitch->switch_lock);
--> 1247         err = npc_install_flow(rvu, blkaddr, target, nixlf, pfvf,
                                                              ^^^^^
Potentially passing an uninitialized value.

    1248                                req, rsp, enable, pf_set_vfs_mac);
    1249         mutex_unlock(&rswitch->switch_lock);
    1250 
    1251         return err;
    1252 }

regards,
dan carpenter

                 reply	other threads:[~2021-11-30 10:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211130104358.GF5827@kili \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=rsaladi2@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.