From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E82DF42B2C; Wed, 17 May 2023 18:16:17 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E28C242D29; Wed, 17 May 2023 18:16:09 +0200 (CEST) Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by mails.dpdk.org (Postfix) with ESMTP id 891FE406B7 for ; Wed, 17 May 2023 18:16:08 +0200 (CEST) Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-64354231003so143308b3a.0 for ; Wed, 17 May 2023 09:16:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1684340167; x=1686932167; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=x28BgXhxXlzUC6u61ZFSHQ/XLofM5ks0SWUjiEZpX38=; b=jJf55Q3zL3lV7MM+HoI7sBI10ahNJYcinCIjMKBEQIAn0ADc7ojfuo21NGxMlht7T7 R8Nl7UtLCR0YSaaD1n74lSQ5HRcIgdvuhXIZfh6QkOyZDRKQSCdVqLPD+xXAWBCU+Q5Q HbzSXtF1kngL7UccYZ2wug7a4yl1klQbwbgILATXIs9A2+6nDNJsZcHPNFffuHX7Fct8 qjg4E5vk/dzVyt2uSpddSwAhlJnT4JC+IlK4wFoOfRSu9txKPoYgvQ3+ghBh/i/uIAVI JEeTv2jnfxKnPdc9iMrp1mF9+BEKkcR6ZNN1S14SfeMCC+/2GzoLv5CKZJKlCdYwsTqb 3V7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684340167; x=1686932167; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=x28BgXhxXlzUC6u61ZFSHQ/XLofM5ks0SWUjiEZpX38=; b=J1cnX21LwEPMmpnMI/58CPCp2ZElLBZzn3a5nTLIzCvbsV2AmTkVGvFU0kec3t+Nma 3tm1mEbRvf87bsP+/U5/2bSP+nZ1t8/Q5XmNPwDwajP3x+DMjibeITOJJtoSa2rgswVl uK+8AJBvsHZIV0wHnkRdKWUbldPlsFLCqfOt0FzwwGnIYjFsBGWPDUDMu3pWgHdyICcM HCCgo+8ZJpESYf1KzmfEKZy+lmVMIWoah8M7+SDZJzzefIauJDmOe0dBL0fyI2ZF1An2 zMCwo9Z9XwT4PWkn3qAx/nu8s2Zo+tU/CfKoKooTow9vpMNF0LZ0n5Nz9DhfirOS+r3x L/Aw== X-Gm-Message-State: AC+VfDx5DLMQqXc48v7q1f/EvH3YDR/HjY42dTgccKAKgb+F75l5mBRK 20iTmj0KWijwifgI4azTIB4obEXWTzVEBgMfetdW6g== X-Google-Smtp-Source: ACHHUZ4IXr+CTZQhCSU/SNfi0Np+c8v/hNgeEZLs1sbJ4yYgTMUDA6bZLXIUq9I8Cw6Y6kBwuPQuIQ== X-Received: by 2002:a05:6a20:3c9e:b0:104:873:c3be with SMTP id b30-20020a056a203c9e00b001040873c3bemr3323067pzj.12.1684340167051; Wed, 17 May 2023 09:16:07 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id h5-20020a62b405000000b0063f33e216dasm15793009pfn.96.2023.05.17.09.16.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 May 2023 09:16:06 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Olivier Matz , Steven Webster , Matt Peters , Andrew Rybchenko Subject: [PATCH 01/20] mbuf: replace term sanity check Date: Wed, 17 May 2023 09:15:44 -0700 Message-Id: <20230517161603.117728-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230517161603.117728-1-stephen@networkplumber.org> References: <20230517161603.117728-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The term sanity check is on the Tier 2 list of words that should be replaced. Signed-off-by: Stephen Hemminger --- app/test/test_mbuf.c | 30 ++++++------- doc/guides/prog_guide/mbuf_lib.rst | 4 +- drivers/net/avp/avp_ethdev.c | 18 ++++---- drivers/net/sfc/sfc_ef100_rx.c | 6 +-- drivers/net/sfc/sfc_ef10_essb_rx.c | 4 +- drivers/net/sfc/sfc_ef10_rx.c | 4 +- drivers/net/sfc/sfc_rx.c | 2 +- examples/ipv4_multicast/main.c | 2 +- lib/mbuf/rte_mbuf.c | 16 +++---- lib/mbuf/rte_mbuf.h | 71 ++++++++++++++++-------------- lib/mbuf/version.map | 2 +- 11 files changed, 83 insertions(+), 76 deletions(-) diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c index 8d8d3b9386ce..db9bb3caeea2 100644 --- a/app/test/test_mbuf.c +++ b/app/test/test_mbuf.c @@ -261,8 +261,8 @@ test_one_pktmbuf(struct rte_mempool *pktmbuf_pool) GOTO_FAIL("Buffer should be continuous"); memset(hdr, 0x55, MBUF_TEST_HDR2_LEN); - rte_mbuf_sanity_check(m, 1); - rte_mbuf_sanity_check(m, 0); + rte_mbuf_validate(m, 1); + rte_mbuf_validate(m, 0); rte_pktmbuf_dump(stdout, m, 0); /* this prepend should fail */ @@ -1161,7 +1161,7 @@ test_refcnt_mbuf(void) #ifdef RTE_EXEC_ENV_WINDOWS static int -test_failing_mbuf_sanity_check(struct rte_mempool *pktmbuf_pool) +test_failing_mbuf_validate(struct rte_mempool *pktmbuf_pool) { RTE_SET_USED(pktmbuf_pool); return TEST_SKIPPED; @@ -1188,7 +1188,7 @@ verify_mbuf_check_panics(struct rte_mbuf *buf) /* No need to generate a coredump when panicking. */ rl.rlim_cur = rl.rlim_max = 0; setrlimit(RLIMIT_CORE, &rl); - rte_mbuf_sanity_check(buf, 1); /* should panic */ + rte_mbuf_validate(buf, 1); /* should panic */ exit(0); /* return normally if it doesn't panic */ } else if (pid < 0) { printf("Fork Failed\n"); @@ -1202,12 +1202,12 @@ verify_mbuf_check_panics(struct rte_mbuf *buf) } static int -test_failing_mbuf_sanity_check(struct rte_mempool *pktmbuf_pool) +test_failing_mbuf_validate(struct rte_mempool *pktmbuf_pool) { struct rte_mbuf *buf; struct rte_mbuf badbuf; - printf("Checking rte_mbuf_sanity_check for failure conditions\n"); + printf("Checking rte_mbuf_validate for failure conditions\n"); /* get a good mbuf to use to make copies */ buf = rte_pktmbuf_alloc(pktmbuf_pool); @@ -1729,7 +1729,7 @@ test_mbuf_validate_tx_offload(const char *test_name, GOTO_FAIL("%s: mbuf allocation failed!\n", __func__); if (rte_pktmbuf_pkt_len(m) != 0) GOTO_FAIL("%s: Bad packet length\n", __func__); - rte_mbuf_sanity_check(m, 0); + rte_mbuf_validate(m, 0); m->ol_flags = ol_flags; m->tso_segsz = segsize; ret = rte_validate_tx_offload(m); @@ -1936,7 +1936,7 @@ test_pktmbuf_read(struct rte_mempool *pktmbuf_pool) GOTO_FAIL("%s: mbuf allocation failed!\n", __func__); if (rte_pktmbuf_pkt_len(m) != 0) GOTO_FAIL("%s: Bad packet length\n", __func__); - rte_mbuf_sanity_check(m, 0); + rte_mbuf_validate(m, 0); data = rte_pktmbuf_append(m, MBUF_TEST_DATA_LEN2); if (data == NULL) @@ -1985,7 +1985,7 @@ test_pktmbuf_read_from_offset(struct rte_mempool *pktmbuf_pool) if (rte_pktmbuf_pkt_len(m) != 0) GOTO_FAIL("%s: Bad packet length\n", __func__); - rte_mbuf_sanity_check(m, 0); + rte_mbuf_validate(m, 0); /* prepend an ethernet header */ hdr = (struct ether_hdr *)rte_pktmbuf_prepend(m, hdr_len); @@ -2130,7 +2130,7 @@ create_packet(struct rte_mempool *pktmbuf_pool, GOTO_FAIL("%s: mbuf allocation failed!\n", __func__); if (rte_pktmbuf_pkt_len(pkt_seg) != 0) GOTO_FAIL("%s: Bad packet length\n", __func__); - rte_mbuf_sanity_check(pkt_seg, 0); + rte_mbuf_validate(pkt_seg, 0); /* Add header only for the first segment */ if (test_data->flags == MBUF_HEADER && seg == 0) { hdr_len = sizeof(struct rte_ether_hdr); @@ -2342,7 +2342,7 @@ test_pktmbuf_ext_shinfo_init_helper(struct rte_mempool *pktmbuf_pool) GOTO_FAIL("%s: mbuf allocation failed!\n", __func__); if (rte_pktmbuf_pkt_len(m) != 0) GOTO_FAIL("%s: Bad packet length\n", __func__); - rte_mbuf_sanity_check(m, 0); + rte_mbuf_validate(m, 0); ext_buf_addr = rte_malloc("External buffer", buf_len, RTE_CACHE_LINE_SIZE); @@ -2506,8 +2506,8 @@ test_pktmbuf_ext_pinned_buffer(struct rte_mempool *std_pool) GOTO_FAIL("%s: test_pktmbuf_copy(pinned) failed\n", __func__); - if (test_failing_mbuf_sanity_check(pinned_pool) < 0) - GOTO_FAIL("%s: test_failing_mbuf_sanity_check(pinned)" + if (test_failing_mbuf_validate(pinned_pool) < 0) + GOTO_FAIL("%s: test_failing_mbuf_validate(pinned)" " failed\n", __func__); if (test_mbuf_linearize_check(pinned_pool) < 0) @@ -2881,8 +2881,8 @@ test_mbuf(void) goto err; } - if (test_failing_mbuf_sanity_check(pktmbuf_pool) < 0) { - printf("test_failing_mbuf_sanity_check() failed\n"); + if (test_failing_mbuf_validate(pktmbuf_pool) < 0) { + printf("test_failing_mbuf_validate() failed\n"); goto err; } diff --git a/doc/guides/prog_guide/mbuf_lib.rst b/doc/guides/prog_guide/mbuf_lib.rst index 049357c75563..0accb51a98c7 100644 --- a/doc/guides/prog_guide/mbuf_lib.rst +++ b/doc/guides/prog_guide/mbuf_lib.rst @@ -266,8 +266,8 @@ can be found in several of the sample applications, for example, the IPv4 Multic Debug ----- -In debug mode, the functions of the mbuf library perform sanity checks before any operation (such as, buffer corruption, -bad type, and so on). +In debug mode, the functions of the mbuf library perform consistency checks +before any operation (such as, buffer corruption, bad type, and so on). Use Cases --------- diff --git a/drivers/net/avp/avp_ethdev.c b/drivers/net/avp/avp_ethdev.c index b2a08f563542..627b362555e8 100644 --- a/drivers/net/avp/avp_ethdev.c +++ b/drivers/net/avp/avp_ethdev.c @@ -1231,7 +1231,7 @@ _avp_mac_filter(struct avp_dev *avp, struct rte_mbuf *m) #ifdef RTE_LIBRTE_AVP_DEBUG_BUFFERS static inline void -__avp_dev_buffer_sanity_check(struct avp_dev *avp, struct rte_avp_desc *buf) +__avp_dev_buffer_check(struct avp_dev *avp, struct rte_avp_desc *buf) { struct rte_avp_desc *first_buf; struct rte_avp_desc *pkt_buf; @@ -1272,12 +1272,12 @@ __avp_dev_buffer_sanity_check(struct avp_dev *avp, struct rte_avp_desc *buf) first_buf->pkt_len, pkt_len); } -#define avp_dev_buffer_sanity_check(a, b) \ - __avp_dev_buffer_sanity_check((a), (b)) +#define avp_dev_buffer_check(a, b) \ + __avp_dev_buffer_check((a), (b)) #else /* RTE_LIBRTE_AVP_DEBUG_BUFFERS */ -#define avp_dev_buffer_sanity_check(a, b) do {} while (0) +#define avp_dev_buffer_check(a, b) do {} while (0) #endif @@ -1302,7 +1302,7 @@ avp_dev_copy_from_buffers(struct avp_dev *avp, void *pkt_data; unsigned int i; - avp_dev_buffer_sanity_check(avp, buf); + avp_dev_buffer_check(avp, buf); /* setup the first source buffer */ pkt_buf = avp_dev_translate_buffer(avp, buf); @@ -1370,7 +1370,7 @@ avp_dev_copy_from_buffers(struct avp_dev *avp, rte_pktmbuf_pkt_len(m) = total_length; m->vlan_tci = vlan_tci; - __rte_mbuf_sanity_check(m, 1); + __rte_mbuf_validate(m, 1); return m; } @@ -1614,7 +1614,7 @@ avp_dev_copy_to_buffers(struct avp_dev *avp, char *pkt_data; unsigned int i; - __rte_mbuf_sanity_check(mbuf, 1); + __rte_mbuf_validate(mbuf, 1); m = mbuf; src_offset = 0; @@ -1680,7 +1680,7 @@ avp_dev_copy_to_buffers(struct avp_dev *avp, first_buf->vlan_tci = mbuf->vlan_tci; } - avp_dev_buffer_sanity_check(avp, buffers[0]); + avp_dev_buffer_check(avp, buffers[0]); return total_length; } @@ -1798,7 +1798,7 @@ avp_xmit_scattered_pkts(void *tx_queue, #ifdef RTE_LIBRTE_AVP_DEBUG_BUFFERS for (i = 0; i < nb_pkts; i++) - avp_dev_buffer_sanity_check(avp, tx_bufs[i]); + avp_dev_buffer_check(avp, tx_bufs[i]); #endif /* send the packets */ diff --git a/drivers/net/sfc/sfc_ef100_rx.c b/drivers/net/sfc/sfc_ef100_rx.c index 16cd8524d32f..fe8920b12590 100644 --- a/drivers/net/sfc/sfc_ef100_rx.c +++ b/drivers/net/sfc/sfc_ef100_rx.c @@ -178,7 +178,7 @@ sfc_ef100_rx_qrefill(struct sfc_ef100_rxq *rxq) struct sfc_ef100_rx_sw_desc *rxd; rte_iova_t dma_addr; - __rte_mbuf_raw_sanity_check(m); + __rte_mbuf_raw_validate(m); dma_addr = rte_mbuf_data_iova_default(m); if (rxq->flags & SFC_EF100_RXQ_NIC_DMA_MAP) { @@ -541,7 +541,7 @@ sfc_ef100_rx_process_ready_pkts(struct sfc_ef100_rxq *rxq, rxq->ready_pkts--; pkt = sfc_ef100_rx_next_mbuf(rxq); - __rte_mbuf_raw_sanity_check(pkt); + __rte_mbuf_raw_validate(pkt); RTE_BUILD_BUG_ON(sizeof(pkt->rearm_data[0]) != sizeof(rxq->rearm_data)); @@ -565,7 +565,7 @@ sfc_ef100_rx_process_ready_pkts(struct sfc_ef100_rxq *rxq, struct rte_mbuf *seg; seg = sfc_ef100_rx_next_mbuf(rxq); - __rte_mbuf_raw_sanity_check(seg); + __rte_mbuf_raw_validate(seg); seg->data_off = RTE_PKTMBUF_HEADROOM; diff --git a/drivers/net/sfc/sfc_ef10_essb_rx.c b/drivers/net/sfc/sfc_ef10_essb_rx.c index 78bd430363b1..de80be462a0f 100644 --- a/drivers/net/sfc/sfc_ef10_essb_rx.c +++ b/drivers/net/sfc/sfc_ef10_essb_rx.c @@ -125,7 +125,7 @@ sfc_ef10_essb_next_mbuf(const struct sfc_ef10_essb_rxq *rxq, struct rte_mbuf *m; m = (struct rte_mbuf *)((uintptr_t)mbuf + rxq->buf_stride); - __rte_mbuf_raw_sanity_check(m); + __rte_mbuf_raw_validate(m); return m; } @@ -136,7 +136,7 @@ sfc_ef10_essb_mbuf_by_index(const struct sfc_ef10_essb_rxq *rxq, struct rte_mbuf *m; m = (struct rte_mbuf *)((uintptr_t)mbuf + idx * rxq->buf_stride); - __rte_mbuf_raw_sanity_check(m); + __rte_mbuf_raw_validate(m); return m; } diff --git a/drivers/net/sfc/sfc_ef10_rx.c b/drivers/net/sfc/sfc_ef10_rx.c index 7be224c9c412..f6c2345d2b74 100644 --- a/drivers/net/sfc/sfc_ef10_rx.c +++ b/drivers/net/sfc/sfc_ef10_rx.c @@ -148,7 +148,7 @@ sfc_ef10_rx_qrefill(struct sfc_ef10_rxq *rxq) struct sfc_ef10_rx_sw_desc *rxd; rte_iova_t phys_addr; - __rte_mbuf_raw_sanity_check(m); + __rte_mbuf_raw_validate(m); SFC_ASSERT((id & ~ptr_mask) == 0); rxd = &rxq->sw_ring[id]; @@ -297,7 +297,7 @@ sfc_ef10_rx_process_event(struct sfc_ef10_rxq *rxq, efx_qword_t rx_ev, rxd = &rxq->sw_ring[pending++ & ptr_mask]; m = rxd->mbuf; - __rte_mbuf_raw_sanity_check(m); + __rte_mbuf_raw_validate(m); m->data_off = RTE_PKTMBUF_HEADROOM; rte_pktmbuf_data_len(m) = seg_len; diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c index 5ea98187c3b4..d9f99a9d583d 100644 --- a/drivers/net/sfc/sfc_rx.c +++ b/drivers/net/sfc/sfc_rx.c @@ -120,7 +120,7 @@ sfc_efx_rx_qrefill(struct sfc_efx_rxq *rxq) ++i, id = (id + 1) & rxq->ptr_mask) { m = objs[i]; - __rte_mbuf_raw_sanity_check(m); + __rte_mbuf_raw_validate(m); rxd = &rxq->sw_desc[id]; rxd->mbuf = m; diff --git a/examples/ipv4_multicast/main.c b/examples/ipv4_multicast/main.c index 6d0a8501eff5..4be74e7af55a 100644 --- a/examples/ipv4_multicast/main.c +++ b/examples/ipv4_multicast/main.c @@ -258,7 +258,7 @@ mcast_out_pkt(struct rte_mbuf *pkt, int use_clone) hdr->pkt_len = (uint16_t)(hdr->data_len + pkt->pkt_len); hdr->nb_segs = pkt->nb_segs + 1; - __rte_mbuf_sanity_check(hdr, 1); + __rte_mbuf_validate(hdr, 1); return hdr; } /* >8 End of mcast_out_kt. */ diff --git a/lib/mbuf/rte_mbuf.c b/lib/mbuf/rte_mbuf.c index 686e797c80c4..6afa9de98d4e 100644 --- a/lib/mbuf/rte_mbuf.c +++ b/lib/mbuf/rte_mbuf.c @@ -363,9 +363,9 @@ rte_pktmbuf_pool_create_extbuf(const char *name, unsigned int n, return mp; } -/* do some sanity checks on a mbuf: panic if it fails */ +/* do some checks on a mbuf: panic if it fails */ void -rte_mbuf_sanity_check(const struct rte_mbuf *m, int is_header) +rte_mbuf_validate(const struct rte_mbuf *m, int is_header) { const char *reason; @@ -492,7 +492,7 @@ void rte_pktmbuf_free_bulk(struct rte_mbuf **mbufs, unsigned int count) if (unlikely(m == NULL)) continue; - __rte_mbuf_sanity_check(m, 1); + __rte_mbuf_validate(m, 1); do { m_next = m->next; @@ -542,7 +542,7 @@ rte_pktmbuf_clone(struct rte_mbuf *md, struct rte_mempool *mp) return NULL; } - __rte_mbuf_sanity_check(mc, 1); + __rte_mbuf_validate(mc, 1); return mc; } @@ -592,7 +592,7 @@ rte_pktmbuf_copy(const struct rte_mbuf *m, struct rte_mempool *mp, struct rte_mbuf *mc, *m_last, **prev; /* garbage in check */ - __rte_mbuf_sanity_check(m, 1); + __rte_mbuf_validate(m, 1); /* check for request to copy at offset past end of mbuf */ if (unlikely(off >= m->pkt_len)) @@ -656,7 +656,7 @@ rte_pktmbuf_copy(const struct rte_mbuf *m, struct rte_mempool *mp, } /* garbage out check */ - __rte_mbuf_sanity_check(mc, 1); + __rte_mbuf_validate(mc, 1); return mc; } @@ -667,7 +667,7 @@ rte_pktmbuf_dump(FILE *f, const struct rte_mbuf *m, unsigned dump_len) unsigned int len; unsigned int nb_segs; - __rte_mbuf_sanity_check(m, 1); + __rte_mbuf_validate(m, 1); fprintf(f, "dump mbuf at %p, iova=%#" PRIx64 ", buf_len=%u\n", m, rte_mbuf_iova_get(m), m->buf_len); @@ -685,7 +685,7 @@ rte_pktmbuf_dump(FILE *f, const struct rte_mbuf *m, unsigned dump_len) nb_segs = m->nb_segs; while (m && nb_segs != 0) { - __rte_mbuf_sanity_check(m, 0); + __rte_mbuf_validate(m, 0); fprintf(f, " segment at %p, data=%p, len=%u, off=%u, refcnt=%u\n", m, rte_pktmbuf_mtod(m, void *), diff --git a/lib/mbuf/rte_mbuf.h b/lib/mbuf/rte_mbuf.h index 913c459b1cc6..919545b775a1 100644 --- a/lib/mbuf/rte_mbuf.h +++ b/lib/mbuf/rte_mbuf.h @@ -339,13 +339,13 @@ rte_pktmbuf_priv_flags(struct rte_mempool *mp) #ifdef RTE_LIBRTE_MBUF_DEBUG -/** check mbuf type in debug mode */ -#define __rte_mbuf_sanity_check(m, is_h) rte_mbuf_sanity_check(m, is_h) +/** do mbuf type in debug mode */ +#define __rte_mbuf_validate(m, is_h) rte_mbuf_validate(m, is_h) #else /* RTE_LIBRTE_MBUF_DEBUG */ -/** check mbuf type in debug mode */ -#define __rte_mbuf_sanity_check(m, is_h) do { } while (0) +/** ignore mbuf checks if not in debug mode */ +#define __rte_mbuf_validate(m, is_h) do { } while (0) #endif /* RTE_LIBRTE_MBUF_DEBUG */ @@ -514,7 +514,7 @@ rte_mbuf_ext_refcnt_update(struct rte_mbuf_ext_shared_info *shinfo, /** - * Sanity checks on an mbuf. + * Consistency checks on an mbuf. * * Check the consistency of the given mbuf. The function will cause a * panic if corruption is detected. @@ -526,12 +526,19 @@ rte_mbuf_ext_refcnt_update(struct rte_mbuf_ext_shared_info *shinfo, * of a packet (in this case, some fields like nb_segs are not checked) */ void -rte_mbuf_sanity_check(const struct rte_mbuf *m, int is_header); +rte_mbuf_validate(const struct rte_mbuf *m, int is_header); + +/* Older deprecated name for rte_mbuf_validate() */ +static inline __rte_deprecated +void rte_mbuf_sanity_check(const struct rte_mbuf *m, int is_header) +{ + rte_mbuf_validate(m, is_header); +} /** - * Sanity checks on a mbuf. + * Do consistency checks on a mbuf. * - * Almost like rte_mbuf_sanity_check(), but this function gives the reason + * Almost like rte_mbuf_validate(), but this function gives the reason * if corruption is detected rather than panic. * * @param m @@ -551,7 +558,7 @@ int rte_mbuf_check(const struct rte_mbuf *m, int is_header, const char **reason); /** - * Sanity checks on a reinitialized mbuf in debug mode. + * Do checks on a reinitialized mbuf in debug mode. * * Check the consistency of the given reinitialized mbuf. * The function will cause a panic if corruption is detected. @@ -563,16 +570,16 @@ int rte_mbuf_check(const struct rte_mbuf *m, int is_header, * The mbuf to be checked. */ static __rte_always_inline void -__rte_mbuf_raw_sanity_check(__rte_unused const struct rte_mbuf *m) +__rte_mbuf_raw_validate(__rte_unused const struct rte_mbuf *m) { RTE_ASSERT(rte_mbuf_refcnt_read(m) == 1); RTE_ASSERT(m->next == NULL); RTE_ASSERT(m->nb_segs == 1); - __rte_mbuf_sanity_check(m, 0); + __rte_mbuf_validate(m, 0); } /** For backwards compatibility. */ -#define MBUF_RAW_ALLOC_CHECK(m) __rte_mbuf_raw_sanity_check(m) +#define MBUF_RAW_ALLOC_CHECK(m) __rte_mbuf_raw_validate(m) /** * Allocate an uninitialized mbuf from mempool *mp*. @@ -599,7 +606,7 @@ static inline struct rte_mbuf *rte_mbuf_raw_alloc(struct rte_mempool *mp) if (rte_mempool_get(mp, (void **)&m) < 0) return NULL; - __rte_mbuf_raw_sanity_check(m); + __rte_mbuf_raw_validate(m); return m; } @@ -622,7 +629,7 @@ rte_mbuf_raw_free(struct rte_mbuf *m) { RTE_ASSERT(!RTE_MBUF_CLONED(m) && (!RTE_MBUF_HAS_EXTBUF(m) || RTE_MBUF_HAS_PINNED_EXTBUF(m))); - __rte_mbuf_raw_sanity_check(m); + __rte_mbuf_raw_validate(m); rte_mempool_put(m->pool, m); } @@ -886,7 +893,7 @@ static inline void rte_pktmbuf_reset(struct rte_mbuf *m) rte_pktmbuf_reset_headroom(m); m->data_len = 0; - __rte_mbuf_sanity_check(m, 1); + __rte_mbuf_validate(m, 1); } /** @@ -942,22 +949,22 @@ static inline int rte_pktmbuf_alloc_bulk(struct rte_mempool *pool, switch (count % 4) { case 0: while (idx != count) { - __rte_mbuf_raw_sanity_check(mbufs[idx]); + __rte_mbuf_raw_validate(mbufs[idx]); rte_pktmbuf_reset(mbufs[idx]); idx++; /* fall-through */ case 3: - __rte_mbuf_raw_sanity_check(mbufs[idx]); + __rte_mbuf_raw_validate(mbufs[idx]); rte_pktmbuf_reset(mbufs[idx]); idx++; /* fall-through */ case 2: - __rte_mbuf_raw_sanity_check(mbufs[idx]); + __rte_mbuf_raw_validate(mbufs[idx]); rte_pktmbuf_reset(mbufs[idx]); idx++; /* fall-through */ case 1: - __rte_mbuf_raw_sanity_check(mbufs[idx]); + __rte_mbuf_raw_validate(mbufs[idx]); rte_pktmbuf_reset(mbufs[idx]); idx++; /* fall-through */ @@ -1185,8 +1192,8 @@ static inline void rte_pktmbuf_attach(struct rte_mbuf *mi, struct rte_mbuf *m) mi->pkt_len = mi->data_len; mi->nb_segs = 1; - __rte_mbuf_sanity_check(mi, 1); - __rte_mbuf_sanity_check(m, 0); + __rte_mbuf_validate(mi, 1); + __rte_mbuf_validate(m, 0); } /** @@ -1341,7 +1348,7 @@ static inline int __rte_pktmbuf_pinned_extbuf_decref(struct rte_mbuf *m) static __rte_always_inline struct rte_mbuf * rte_pktmbuf_prefree_seg(struct rte_mbuf *m) { - __rte_mbuf_sanity_check(m, 0); + __rte_mbuf_validate(m, 0); if (likely(rte_mbuf_refcnt_read(m) == 1)) { @@ -1412,7 +1419,7 @@ static inline void rte_pktmbuf_free(struct rte_mbuf *m) struct rte_mbuf *m_next; if (m != NULL) - __rte_mbuf_sanity_check(m, 1); + __rte_mbuf_validate(m, 1); while (m != NULL) { m_next = m->next; @@ -1493,7 +1500,7 @@ rte_pktmbuf_copy(const struct rte_mbuf *m, struct rte_mempool *mp, */ static inline void rte_pktmbuf_refcnt_update(struct rte_mbuf *m, int16_t v) { - __rte_mbuf_sanity_check(m, 1); + __rte_mbuf_validate(m, 1); do { rte_mbuf_refcnt_update(m, v); @@ -1510,7 +1517,7 @@ static inline void rte_pktmbuf_refcnt_update(struct rte_mbuf *m, int16_t v) */ static inline uint16_t rte_pktmbuf_headroom(const struct rte_mbuf *m) { - __rte_mbuf_sanity_check(m, 0); + __rte_mbuf_validate(m, 0); return m->data_off; } @@ -1524,7 +1531,7 @@ static inline uint16_t rte_pktmbuf_headroom(const struct rte_mbuf *m) */ static inline uint16_t rte_pktmbuf_tailroom(const struct rte_mbuf *m) { - __rte_mbuf_sanity_check(m, 0); + __rte_mbuf_validate(m, 0); return (uint16_t)(m->buf_len - rte_pktmbuf_headroom(m) - m->data_len); } @@ -1539,7 +1546,7 @@ static inline uint16_t rte_pktmbuf_tailroom(const struct rte_mbuf *m) */ static inline struct rte_mbuf *rte_pktmbuf_lastseg(struct rte_mbuf *m) { - __rte_mbuf_sanity_check(m, 1); + __rte_mbuf_validate(m, 1); while (m->next != NULL) m = m->next; return m; @@ -1583,7 +1590,7 @@ static inline struct rte_mbuf *rte_pktmbuf_lastseg(struct rte_mbuf *m) static inline char *rte_pktmbuf_prepend(struct rte_mbuf *m, uint16_t len) { - __rte_mbuf_sanity_check(m, 1); + __rte_mbuf_validate(m, 1); if (unlikely(len > rte_pktmbuf_headroom(m))) return NULL; @@ -1618,7 +1625,7 @@ static inline char *rte_pktmbuf_append(struct rte_mbuf *m, uint16_t len) void *tail; struct rte_mbuf *m_last; - __rte_mbuf_sanity_check(m, 1); + __rte_mbuf_validate(m, 1); m_last = rte_pktmbuf_lastseg(m); if (unlikely(len > rte_pktmbuf_tailroom(m_last))) @@ -1646,7 +1653,7 @@ static inline char *rte_pktmbuf_append(struct rte_mbuf *m, uint16_t len) */ static inline char *rte_pktmbuf_adj(struct rte_mbuf *m, uint16_t len) { - __rte_mbuf_sanity_check(m, 1); + __rte_mbuf_validate(m, 1); if (unlikely(len > m->data_len)) return NULL; @@ -1678,7 +1685,7 @@ static inline int rte_pktmbuf_trim(struct rte_mbuf *m, uint16_t len) { struct rte_mbuf *m_last; - __rte_mbuf_sanity_check(m, 1); + __rte_mbuf_validate(m, 1); m_last = rte_pktmbuf_lastseg(m); if (unlikely(len > m_last->data_len)) @@ -1700,7 +1707,7 @@ static inline int rte_pktmbuf_trim(struct rte_mbuf *m, uint16_t len) */ static inline int rte_pktmbuf_is_contiguous(const struct rte_mbuf *m) { - __rte_mbuf_sanity_check(m, 1); + __rte_mbuf_validate(m, 1); return m->nb_segs == 1; } diff --git a/lib/mbuf/version.map b/lib/mbuf/version.map index ed486ed14ec7..e968c54a0807 100644 --- a/lib/mbuf/version.map +++ b/lib/mbuf/version.map @@ -27,7 +27,6 @@ DPDK_23 { rte_mbuf_dynflag_register; rte_mbuf_dynflag_register_bitnum; rte_mbuf_platform_mempool_ops; - rte_mbuf_sanity_check; rte_mbuf_set_platform_mempool_ops; rte_mbuf_set_user_mempool_ops; rte_mbuf_user_mempool_ops; @@ -39,6 +38,7 @@ DPDK_23 { rte_pktmbuf_pool_create; rte_pktmbuf_pool_create_by_ops; rte_pktmbuf_pool_init; + rte_mbuf_validate; local: *; }; -- 2.39.2