From 942aa8f8d56507fd492e4e4202772c9353723cd3 Mon Sep 17 00:00:00 2001 From: Amir Levy Date: Mon, 4 May 2020 11:59:14 +0300 Subject: [PATCH] msm: ipa: warn if header type isn't compatible with mode In case of Vlan mode, verify that registered header is of correct type and warn otherwise. Change-Id: Ic5c529f1c9cabf77d0ef9f996105014d4a272c7c Signed-off-by: Amir Levy --- .../msm/ipa/ipa_clients/ipa_uc_offload.c | 40 ++++++++++++++++++- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/drivers/platform/msm/ipa/ipa_clients/ipa_uc_offload.c b/drivers/platform/msm/ipa/ipa_clients/ipa_uc_offload.c index 807c75a1ace8..1078e47d4135 100644 --- a/drivers/platform/msm/ipa/ipa_clients/ipa_uc_offload.c +++ b/drivers/platform/msm/ipa/ipa_clients/ipa_uc_offload.c @@ -1,10 +1,11 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2015-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2015-2020, The Linux Foundation. All rights reserved. */ #include #include +#include #include "../ipa_common_i.h" #include "../ipa_v3/ipa_pm.h" @@ -160,7 +161,7 @@ static int ipa_uc_offload_ntn_reg_intf( struct ipa_ioc_rx_intf_prop rx_prop[2]; int ret = 0; u32 len; - + bool is_vlan_mode; IPA_UC_OFFLOAD_DBG("register interface for netdev %s\n", inp->netdev_name); @@ -182,6 +183,41 @@ static int ipa_uc_offload_ntn_reg_intf( goto fail_alloc; } + ret = ipa_is_vlan_mode(IPA_VLAN_IF_ETH, &is_vlan_mode); + if (ret) { + IPA_UC_OFFLOAD_ERR("get vlan mode failed\n"); + goto fail; + } + + if (is_vlan_mode) { + if ((inp->hdr_info[0].hdr_type != IPA_HDR_L2_802_1Q) || + (inp->hdr_info[1].hdr_type != IPA_HDR_L2_802_1Q)) { + IPA_UC_OFFLOAD_ERR( + "hdr_type mismatch in vlan mode\n"); + WARN_ON_RATELIMIT_IPA(1); + ret = -EFAULT; + goto fail; + } + IPA_UC_OFFLOAD_DBG("vlan HEADER type compatible\n"); + + if ((inp->hdr_info[0].hdr_len < + (ETH_HLEN + VLAN_HLEN)) || + (inp->hdr_info[1].hdr_len < + (ETH_HLEN + VLAN_HLEN))) { + IPA_UC_OFFLOAD_ERR( + "hdr_len shorter than vlan len (%u) (%u)\n" + , inp->hdr_info[0].hdr_len + , inp->hdr_info[1].hdr_len); + WARN_ON_RATELIMIT_IPA(1); + ret = -EFAULT; + goto fail; + } + + IPA_UC_OFFLOAD_DBG("vlan HEADER len compatible (%u) (%u)\n", + inp->hdr_info[0].hdr_len, + inp->hdr_info[1].hdr_len); + } + if (ipa_commit_partial_hdr(hdr, ntn_ctx->netdev_name, inp->hdr_info)) { IPA_UC_OFFLOAD_ERR("fail to commit partial headers\n"); ret = -EFAULT;